[SETTINGS]
- Symfony 3.4
- Package entity : [id, form_id, maretial_id, design_id]
- Form entity : [id, form_name]
- Material entity : [id, material_name, form_id]
- Design entity : [id, design_name, material_id]
[PROBLEM]
I would like to know how to supplement a form with data from an Ajax request.
In my main form, I can select only select the package form (form_id)
.
Once it's selected, via an Ajax request, I will look up for every material objects which are compatible with the selected form
:
Form my controller, I'm calling my form builder :
<kbd>FormMaterialsType.php</kbd>
public function buildSupplementForm(FormBuilderInterface $builder, array $options) {
$builder
->add('material', EntityType::class, array(
'class' => 'AppBundle\Entity\Material',
'choice_label' => 'Material',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('m')
->where('m.form= :form');
->setParameters(array(
new Parameter('form', $options['form_id']),
))
},
'empty_data' => null,
'required' => true)
);
}
The problem is that I'm getting a full form. How can I get only the select
bloc?