我有一个有验证的 cakephp 表单。验证本身有效,但是当单击提交后出现错误时,它只会产生一些文本。
为什么我没有颜色。例如,它的意思是用红色显示错误。
控制器
<div class="users form">
<?php echo $this->Form->create('Ticket'); ?>
<fieldset>
<legend><?php echo __('Purchase'); ?></legend>
<?php
echo $this->Form->input('first_name');
echo $this->Form->input('last_name');
echo $this->Form->input('email');
echo $this->Form->input('phone');
echo $this->Form->input('date', array('options'=> $dates));
echo $this->Form->input('quantity', array('options' => $maxAmount, 'default' => '1'));
?>
</fieldset>
<?php
echo $this->Form->end(__('Purchase'));
?>
</div>
模型
public $validate = array(
'first_name' => array(
'rule' => '/^[a-zA-Z]{1,}$/i',
'message' => 'Alphabets only',
'required' => true
),
'last_name' => array(
'rule' => '/^[a-zA-Z]{1,}$/i',
'message' => 'Alphabet only',
'required' => true
),
'phone' => array(
'rule' => 'numeric',
'message' => 'numbers only please',
'required' => true
),
'email' => array(
'rule' => 'email',
'message' => 'Your email is not valid',
'required' => true
),
'quantity' => array(
'rule' => 'numeric',
'message' => 'numbers only please',
'required' => true
)
);