symfony - Symfony2 - Dynamically modify form using user inputs -
a little bit of background first. learned in past how use "pure" php, , have more started using symfony. have been following several guides (cookbook, lynda & openclassrooms) many of inquiries, haven't been able find answer current question.
i have 2 entities, let's name them user , player. user entity contains player property can null.
so, during user creation, 3 possibilities : leave player field empty, select already-existing player, or create new player. @ first wanted add "create new" option in player dropdown list, have gone "create new player" checkbox.
the idea is, if checkbox checked, remove player dropdown list , add embedded form create new player. have tried several events (pre_set_data, pre_submit & co), none seem trigger according user input.
this have done in jscript, seeing how symfony's different animal pure php, don't know how it. or advice appreciated !
you're on right track there pre_set_data
, pre_submit
events.
you need use javascript reload form server , symfony form events rebuild form.
this documentation you're looking for: http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html
unfortunately, symfony's form component pretty complicated, there no simple code examples can take , use without going through article.
also reading form events documentation helpful deeper understanding.
Comments
Post a Comment