3

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 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!

1 Answer 1

4

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.
Sign up to request clarification or add additional context in comments.

1 Comment

thanks I tried your second suggestion and it works: ) first i call $form->updateObject() method manually it returns object.this object is not persisted in database. And that is what i want...Thank you!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.