こんにちは、数値フィールドのあるフォームがあります。正規表現を使用してフィールドを検証します。そのため、パターン属性を要素に追加しました。ただし、formText を使用すると、html は正規表現パターンをエスケープします。
//inside the form _construct
$this->add(array(
'name' => 'number',
'type' => 'text',
'options' => array(
'label' => 'Number',
),
'attributes' => array(
'pattern' => '/^(\+)?((\d)+(-|\s)?)+$/',
'maxLength' => '20',
'id' => 'number',
),
));
そしてその形で
<?php echo $this->formText($form->get('number')); ?>
その時の結果は
<input type="text" name="number" pattern="/^(\+)?((\d)+(-|\s)?)+$/" id="number" value="" maxlength="20">
正規表現パターンをエスケープせずに数値フィールドをフォームに追加するにはどうすればよいですか?