BagoZonde Posted July 24, 2014 Share Posted July 24, 2014 Hello! Is anybody know how to build Symfony 2 form (using Doctrine 2 and annotations) described as: 1. I have KingEntity which contains "type", "settings" and "something_else" fields. "Settings" field will contain serialized data as it can differ depending on "type" selected. 2. When type==1 I want get child-form (or something like that) QueenOne. And when type==2, I want get child-form QueenTwo, and so on. Each Queen* form contains different fields that's why I want to serialize it and put in "settings" field. I don't want to create new tables in database and create relations between them at all. 3. So, if type==1 is selected, I want validate this form using QueenOne form. If validation success, I want to serialize that data from QueenOne and put into "settings" field of KingEntity, so KingEntity is keeped in database and it contains only "type", "settings" and "something_else" fields. 4. I'm not interested with viewing this form, I need only backend part of logic for this kind of form. I hope I've explained it clearly. Any help will be appreciated. Link to comment https://forums.phpfreaks.com/topic/290093-including-changeable-nested-form-depending-on-chosen-field-value-and-serialize/ Share on other sites More sharing options...
BagoZonde Posted July 27, 2014 Author Share Posted July 27, 2014 Ok, it was really easy thanks to validation_groups so all fields are available in one entity but splitted into groups. About serializing these fields to one "settings" field, I've used callbacks in that same entity like postLoad, prePersist and preUpdate. Case closed. Link to comment https://forums.phpfreaks.com/topic/290093-including-changeable-nested-form-depending-on-chosen-field-value-and-serialize/#findComment-1486220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.