我有以下表格:
<?php echo $this->Html->image('itemdefault.gif',array('class'=>'image1')); ?>
<?php echo $this->form->input('quantity',array('class'=>'input')); ?><br>
<?php echo $this->form->input('SpecialInstructions', array('type'=>'select','style'=>'font-size:13pt;width:120px;','options'=>$spec_ins)); ?><br>
<?php echo $this->form->input('Ingredients',array('class'=>'input')); ?><br>
<?php echo $this->form->end('Save',array('class'=>'button1'));
这是模型中的验证:
var $validate=array
(
'quantity'=>array
(
'numeric'=>array('rule'=>'numeric','required'=>true,'message'=>'Enter numbers only'),
'qty_must_not_be_blank'=>array('rule'=>'notEmpty','message'=>'Quantity cannot be left blank')
),
'Ingredients'=>array
(
'body_must-not_be_blank'=>array('rule'=>'notEmpty','message'=>'Body must not be blank')
)
);
但验证都没有奏效。是因为我的数据库中不存在这些字段吗?
答案 0 :(得分:0)
echo $this->Form->create();
您的代码中缺少。尝试在代码的开头包含它