Я получаю следующую ошибку при попытке передать параметр моему методу buildForm
в одной из моих форм.
Параметр «numOfHoles» не существует. Определенные параметры: «действие», «allow_extra_fields», «attr», «auto_initialize», «block_name», «by_reference», «cascade_validation», «соединение» "," ограничения "," csrf_field_name "," csrf_message "," csrf_protection "," csrf_provider "," csrf_token_id "," csrf_token_manager "," data "," data_class "," disabled "," empty_data " error_mapping, extra_fields_message, inherit_data, «намерение», «invalid_message», «invalid_message_parameters», «label», «label_attr», «label_format», «mapped», «max_length», «method», «шаблон» "," post_max_size_message "," property_path "," read_only "," required "," translation_domain "," trim "," validation_groups "," virtual ".
В моем контроллере:
// hardcoded here for brevity in this example
$form = $this->createForm('crmpicco_course_row', $courseRow, array('numOfHoles' => 18));
В crmpicco_course_row
классе формы:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text')
->add('course', 'crmpicco_course', array('numOfHoles' => $options['numOfHoles']))
;
}
В crmpicco_course
классе формы:
public function buildForm(FormBuilderInterface $builder, array $options)
{
for ($i = 0; $i < $options['numOfHoles']; $i++) {
$builder->add($i, 'text', array('required' => 'false'));
}
}
/**
* @return string name
*/
public function getName()
{
return 'crmpicco_course';
}
Кто-нибудь может понять, почему не протягивает вариант numOfHoles
?
numOfHoles
, используя функциюsetDefaults
илиsetRequired
внутриconfigureOptions(OptionsResolver $resolver)
вашего конструктора форм. - person gp_sflover   schedule 26.10.2015