php - CakePHP validate fields that aren't in the Database -
i have form values aren't in database. wan't validation on them made validation rules using field names. somehow validation rules aren't being used.
i tried set different rules. file names correct since $hasmany connection works.
i hope can help!
form:
<?php echo $this->form->create('map'); echo $this->form->input('min_x'); echo $this->form->input('max_x'); echo $this->form->input('min_y'); echo $this->form->input('max_y'); echo $this->form->end('submit'); ?>
validation rules:
public $validate = array( 'min_x' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ), 'max_x' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ), 'min_y' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ), 'max_y' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ), );
rules validation case sensitive, so:
'rule' => 'numeric',
should changed to
'rule' => 'numeric',
for each instance.
you have comma on last field's array.
public $validate = array( 'min_x' => array( 'numeric' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ) ), 'max_x' => array( 'numeric' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ) ), 'min_y' => array( 'numeric' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ) ), 'max_y' => array( 'numeric' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ) ) );
Comments
Post a Comment