I
I
Ivan Antonov2015-10-05 14:07:54
symfony
Ivan Antonov, 2015-10-05 14:07:54

How to create a complex form in Symfony?

Form is tied to essence. Is it possible to make the form completely change itself when changing only one select?
Simple example:
There is a select with 3 items:

  1. Flat
  2. Land plot
  3. Office

Mandatory items for an apartment are not needed for a land plot and vice versa.
Is it possible for each item to create its own form?
PS: I did not understand the documentation, tell me, please.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Denis, 2015-10-05
@antonowano

remove required from dependent fields, and push the check, depending on the type of property
, either into the listener, or into the validator, or into the manager (service),
or at worst into the controller by adding the FormError form.
On the client, the same logic, respectively.
If you want to get confused and write some abstractions around this form, please contact ...
But for such a trivial task it would be more reasonable to write a mini-crutch in the form of a direct enumeration of the fields.
(Of course it depends on the situation)

S
shagguboy, 2015-10-05
@shagguboy

make three forms and show them with javascript.

I
Ivan Prilepsky, 2015-07-24
@Prilepsky

As a result, I use The Great Suspender extension - I'm satisfied!

V
Vitaliy Petrychuk, 2012-02-18
@vermilion1

chrome.google.com/webstore/detail/kjecajkoiikaohhagojedcphegkcfobm/details?hl=en-US

T
Tesby, 2012-02-19
@Tesby

chrome.google.com/webstore/detail/kokmfemecmlekdnjllgobeplngdfifie?hl=ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question