I have a problem with class form from symfony2. I want to put two forms embededd and get and set values.
Controller:
$form = $this->createFormBuilder($jurisdictionUser)
->add('name', 'text')
->add('security_user', new SecurityUserType(), array('mapped'=>false))
->add('email', 'text', array('required' => false, 'read_only' => true))
->add('roles', 'choice', array('choices' => $appModules->getRolesForJurisdictionForFormChoice(), 'multiple' => true, 'expanded' => true, 'translation_domain' => 'permissions'))
// ->add('services', 'choice', array('multiple' => true, 'expanded' => true, 'translation_domain' => 'permissions'))
->add('services', null, array('multiple' => true, 'expanded' => true,
'choices' => $services,
'property' => 'hierarchy_name'
))
->add('save', 'submit')
->add('save_and_back', 'submit')
->getForm();
SecurityUserType:
class SecurityUserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('first_name', null, ['label' => 'profile.edit.labels.first_name', 'icon_class' => 'fa fa-user'])
->add('last_name', null, ['label' => 'profile.edit.labels.last_name', 'icon_class' => 'fa fa-user'])
->add('nickname', null, ['label' => 'profile.edit.labels.nickname',
'attr' => [ 'help_text' => 'profile.edit.labels.nickname_help'], 'icon_class' => 'fa fa-globe']);
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Radmas\SecurityBundle\Document\SecurityUser'
));
}
public function getName()
{
return 'securityUser';
}
}
How can I get and set values in my form?