私が作成したフォームには、1 つの例外があります。「コストを節約する」ために、モデルの既存のプロパティがこの「新しいフィールド」に使用されます。
私の目標:
- 既存のプロパティのラベルを変更する
- 既存のプロパティの検証を変更する
- 既存のプロパティのエラー メッセージを変更する
検証を追加してラベルを変更する方法を考え出しましたが、既存のフィールドのエラー メッセージを設定する場所が見つからないようです。
// MyFormType.php
<?php
if (!empty($options['unique']) && $options['unique'] == 'some_variable') {
$event->getForm()->add($factory->createNamed('existing_field', 'number', null, array(
'label' => 'Number field',
'required' => true,
'max_length' => 6,
'constraints' => array(
new MinLength(6),
new MaxLength(6),
),
)));
} else {
$event->getForm()->add($factory->createNamed('existing_field', 'text', null, array(
'label' => 'Text field',
)));
}
検証エラー メッセージを設定できるフィールド オプションのキーはありますか?