I found an answer to a similar problem than mine, but I don't understand how it works and what should I change in my code. So I ask you for help, I have this error message :
The option "0" does not exist. Defined options are: "action", "allow_extra_fields", "allow_file_upload", "attr", "auto_initialize", "block_name", "by_reference", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "help", "help_attr", "inherit_data", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "method", "post_max_size_message", "property_path", "required", "translation_domain", "trim", "upload_max_size_message", "validation_groups".
Here is my Type:
<?php
namespace App\Form;
use App\Entity\Equipment;
use App\Entity\Property;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PropertyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('propertyCategory', ChoiceType::class, [
'required' => true,
'choices' => [
'Appartement' => 'Appartement',
'Maison' => 'Maison',
'Garage' => 'Garage',
'Bureau' => 'Bureau',
'Château' => 'Château',
'Commerce' => 'Commerce',
]
])
->add('uniqueName', TextType::class, ['required' => true, 'label' => 'Nom unique'])
->add('address', TextType::class, ['required' => true, 'label' => 'Adresse'])
->add('city', TextType::class, ['required' => true, 'label' => 'Ville'])
->add('zipcode', IntegerType::class, ['required' => true, 'label' => 'Code postal'])
->add('country', CountryType::class, ['required' => true, 'label' => 'Pays'])
->add('surfaceInSquareMeter', IntegerType::class, [
'required' => true,
'label' => 'Surface en m²'
])
->add('numberOfPiece', IntegerType::class, ['required' => true, 'label' => 'Nombre de pièces'])
->add('description', TextType::class, ['required' => false, 'Description'])
->add('equipments', EntityType::class, [
'required' => false,
'label' => 'Equipements',
[
'class' => Equipment::class,
'multiple' => true,
'expanded' => true,
'choice_label' => 'name'
]
])
->add('locationCategory', ChoiceType::class, [
'required' => true,
'choices' => [
'Meublé' => 'Meublé',
'Non meublé' => 'Non meublé',
]
])
->add('rentExcludingCharges', NumberType::class, [
'required' => true,
'label' => 'Loyer hors charges'
])
->add('charges', NumberType::class, ['required' => true, 'label' => 'Charges'])
->add('purchasePrice', NumberType::class, ['required' => true, 'label' => 'Prix d\'achat']);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Property::class,
]);
}
}
Hope you understand my english and someone can help me (and explain me how to avoid to do this mistake again)
Thx
EDIT : there was a problem with those useless[] in
->add('equipments', EntityType::class, [
'required' => false,
'label' => 'Equipements',
[
'class' => Equipment::class,
'multiple' => true,
'expanded' => true,
'choice_label' => 'name'
]
])
, I resolved it but error message is same