php - Symfony formbuilder: Skip one value


I have a entity named Child, which has a ChildType as form, with a ChildRelation form injected in it.

In my code I currently have this, but this validates everything:

$editForm = $this->createForm(ChildType::class, $child);

if ($editForm->isSubmitted() && $editForm->isValid()) {}

Things got more complex, I need the form to process all values, with the errorhandling it does, except for the$child->childrelations array, I want that ignored completely. I want to do this manually. How can I do this without changing a lot of code?

I was thinking something in configureOptions, but I cant find the actual options I need to set then...




Symfony >= 3

To validate a nested entity, you have to use the annotation:@Assert\Valid in your entity's field definition.

If you don't write this annotation, it will be not validated ( from Symfony 3.0)

Symfony < 3.0

You can add the "cascade_validation' => false" option to your from field creation.

People are also looking for solutions to the problem: javascript - Live displaying PHP output on a webpage


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.