Good, I have a form in Symfony of type "type" that shows a series of attributes, but in a specific case I would like to show the whole form except one field.
I tried to pass from the controller to the constructor of the buildForm in the Options parameter a parameter to then collect and do the desired action but it does not work for me.
The code I've tried is this
class FormativeActionType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title',TextType::class, array(
'label' => 'common.title'
))
->add('officialCode',TextType::class, array(
'label' => 'common.officialCode',
'disabledCar' => true,
))
->add('enabled',CheckboxType::class, array(
'required' => false ,
'label' => 'common.enabled'
));
}
}
And from the controller I tried this
$car = new Car();
$form = $this->createForm(CarType::class, $coche, [
'action' => $this->generateUrl('admin_car_new'),
'disabledCar' => true
]);
$form->handleRequest($request);