symfony - Symfony2 My custom form field type isn't populated with data from entity -
i created simple custom field
class inputwithdescriptiontype extends abstracttype { public function configureoptions(optionsresolver $resolver) { $resolver->setdefaults(array( 'description' => '', )); } public function buildform(formbuilderinterface $builder, array $options) { $builder ->setattribute('description', $options['description']) ; } public function buildview(formview $view, forminterface $form, array $options) { $view->vars['description'] = $options['description']; } public function getparent() { return 'text'; } public function getname() { return 'input_with_description'; } }
and added form
$builder ->add('name') ->add('about', 'input_with_description', array( 'description' => "description", 'label' => "label", ))
when submitting form data saved when try edit entity using form custom fields empty. may problem be?
public function configureoptions(optionsresolver $resolver) { $resolver->setdefaults(array( 'data_class' => 'appbundle\entity\product' )); }
replace 'appbundle\entity\product' entity class.
Comments
Post a Comment