私のフォームのbuildForm
メソッドにオプションを渡そうとすると、次のエラーが発生します。コントローラから組み込みsymfonyフォームへのオプションを渡したときにオプションが存在しないエラー
オプション「numOfHoles」は存在しません。定義されたオプションは、 "action"、 "allow_extra_fields"、 "attr"、 "auto_initialize"、 "block_reference"、 "cascade_validation"、 "compound"、 "constraints"、 "csrf_field_name"、 "csrf_message" 「csrf_provider」、「csrf_token_id」、「csrf_token_manager」、「data」、「data_class」、「disabled」、「empty_data」、「error_bubbling」、「error_mapping」、「extra_fields_message」、「inherit_data」、「intention」、 "invalid_message"、 "invalid_message_parameters"、 "label_attr"、 "label_format"、 "mapped"、 "max_length"、 "method"、 "pattern"、 "post_max_size_message"、 "property_path"、 "read_only" 「必要な」、「translation_domain」、「trim」、「validation_groups」、「virtual」です。
crmpicco_course
Formクラスでpublic function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name', 'text') ->add('course', 'crmpicco_course', array('numOfHoles' => $options['numOfHoles'])) ; }
:
私のコントローラで
:crmpicco_course_row
フォームクラスで
// hardcoded here for brevity in this example
$form = $this->createForm('crmpicco_course_row', $courseRow, array('numOfHoles' => 18));
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
がない理由誰もが見ることができますpスルーする?
フォームビルダーの 'configureOptions(OptionsResolver $ resolver)'の中で 'setDefaults'または' setRequired'関数を使って 'numOfHoles'オプションを追加する必要があります。 –