php - Setup parent entity from child entity form -
I am using Symfony2 for a PHP project, but I have a question about the fate of the unit.
I is a database model that requires differentiating between different types of employees.
There is an extraction of modeling here:
employee
- civilization
- first name
- hired_at
- Employees [Employees [unit]]
- Roles [another unit]
- Employee [employee unit]
- Sections [another organization]
I It has to be separated because I am the second institution, which is called a message, that every employee is different Can send to gon
- li>
- sent_at < / Li>
In my application, I want to be able to create a new "secretary" for example, and I'm setting up
Correct to do this with Symfony2 What's the way
I know that I can add properties to the form and set the institutions manually, but I really feel like doing this one It should be a clean way ...
Is it possible to use formulators? In fact, I did not know that it is possible to add another formatting as a field type.
Symfony2
In the case of work, just in case:
named place MyAdminBundle \ Form; Use Symfony \ Component \ Form \ AbstractType; Use Symfony \ Component \ Form \ FormBuilderInterface; Use Symfony \ Component \ OptionsResolver \ OptionsResolverInterface; Class Secretary Type Abertype {/ ** * @ Ultimate Form Builder Interface $ Builder * @ Ultimate Array $ Option * / Public Functions buildForm (FormBuilderInterface $ builder, Array $ option) {$ builder - & gt; Add ('Employee', type new employee), ('password', 'password', array ('label' = & gt; 'password', 'expected') -> ('labels' = & gt; employee' , 'Required' = & gt; true)) - & gt; = & Gt; truth)); } / ** * Ultimate Vendorolver Interface $ Resolver * / Public Function Set Default Option (Optional Interface $ Resolver) {$ Resolver- & gt; Set Defaults (array ('data_class' = & gt; 'MyCoreBundle \ Entity \ Secretary')); } / ** * @ layer string * / public function getName () {return 'my_adminbundle_secretary'; }}
Comments
Post a Comment