I have a form for my object called Book , and I have a type to display the form in my view. In this type, I have some fields that appear in the properties of my object.
Now I want to add another field that does not appear in my entity, and provide some source data for this field during the creation of the form.
My type is as follows
// BookBundle\Type\Book public function buildForm(FormBuilderInterface $builder, array $options = null) { $builder->add('title'); $builder->add('another_field', null, array( 'mapped' => false )); }
The form is created as follows
$book = $repository->find(1); $form = $this->createForm(new BookType(), $book);
How can I provide some source data now during form creation? Or how can I change this form creation to add the source data to another_field ?
php forms symfony entity
Benjamin paap
source share