开发者

Symfony get form model object

开发者 https://www.devze.com 2023-03-14 19:02 出处:网络
In my symfony application I would like to get form model object before calling save method.For example: on form submit I bind it to the related Form 开发者_JAVA技巧Object. And before calling save meth

In my symfony application I would like to get form model object before calling save method.For example: on form submit I bind it to the related Form 开发者_JAVA技巧Object. And before calling save method I want to get related Model object with its submitted values.I know there is $this->form->getObject() method.When I call it before $this->form->save(); method it returns model without values. Is there any way to get it? Any help is appreciated.

Thanks in advance!


The form's values are only set in the object in save(). You have two options:

  1. if the values are enough, use $form->getValues(), it returns the cleaned array
  2. if they aren't, call $form->updateObject() manually.
0

精彩评论

暂无评论...
验证码 换一张
取 消