Validation rules are not being applied on create in cakePHP -


the problem having validation rules being fired on edit, none of them fired on create. here few of validation rules, though problem not here:

var $validate = array(          'date' => array(             'notempty' => array(                 'rule' => array('notempty'),                 'message' => 'choose date'             )             ),          'minutes' => array(             'rule'=>'minutes',             'message' => 'minutes cannot exceed 60',             'allowempty' => true         ) 

and here forms (edit , add):

<?php echo $this->form->create('event');?>      <?php echo $this->form->input('date', array('class'=>'datepicker', 'type'=>'text', 'label'=>__('date*')));?>  <?php echo $this->form->end(__('save edit'));?>    <?php echo $this->form->create('event');?>            <?php   echo $this->form->input('date', array('class'=>'datepicker', 'type'=>'text', 'value'=>$date, 'label'=>__('date*'))); ?>  <?php echo $this->form->end(__('save'));?> 

and validation not disabled in controller function same on app , work every other model. guess has simple, cannot work.

any appreciated.

try code in eventscontroller.php file.

in add() function:

code:

if ($this->request->is('post')) {    $this->event->set($this->request->data);    if($this->event->validates()) {        if ($this->event->save($this->request->data)) {           // data saved , validated        }    }  } 

i hope code you..

thank you!!


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -