cakephp 2 validation error messages do not display -


here model contacts.php

<?php  app::uses('appmodel', 'model'); app::uses('validation', 'utility');  /**  * base application model  *  * @package  croogo  * @link     http://www.croogo.org  */ //$validate = new validator(); //             'alphanumeric' => array( //             'required' => true, //             'allowempty' => false,   class contacts extends appmodel {     var $name = 'contacts';     var $usetable = false;      var $validate = array(         'contactsaddress' => array(              'rule' => 'notempty',              'required' => true,              'message' => 'the address required'),         'contactsemail' => array(                   'rule' => array('email', true),                   'required' => true,                   'message' => 'a valid email required'               ),         'contactsphone' => array(                  'rule' => array('phone', null, 'us'),                  'message' => 'a valid phone numbe required'              )      );     //} } 

contactscontroller.php

app::uses('appcontroller', 'controller'); app::uses('validation', 'utility');  class contactscontroller extends appcontroller {   public $helpers = array('form', 'html', 'session', 'js', 'time');   public $uses = array('contacts'); /**  * controller not use model  *  * @var array  */     //public $uses = array(); //public $uses = array('contact'); //use  cake\validation\validator; /**  * displays view  *  * @return void  * @throws notfoundexception when view file not found  *  or missingviewexception in debug mode.  */   public function index() {     $this->contacts->set($this->request->data);     if($this->request->is('post')) {        //if ($this->contact->validation()) {       if ($this->contacts->validates()) {       //    return            $this->contacts->save();           $this->redirect('/contacts/confirm');       }  else { cakelog::write('debug', 'errorcheck');  //      $errors = $this->contacts->validationerrors;          //$this->session->setflash($this->contacts->validationerrors);         //$this->redirect('/contacts'); //cakelog::write('debug', $errors['contactsaddress'][0]); // debugger::dump($errors);          }       }     } 

the view file index.ctp

<!--navigation background part starts --> <div id="navigation-bg">     <!--navigation part starts -->     <div id="navigation">         <ul class="mainmenu">             <li><a href="/"  title="home">home</a></li>             <li><a href="about" title="about">about</a></li>             <li class="nobg"><a href="contact" class="selectmenu" title="contact">contact</a></li>         </ul>         <a href="contact" class="signup" title="appointment"></a>         <br class="spacer" />     </div>     <!--navigation part ends --> </div> <div id="ourcompany-bg"> <div class="requestform"> <p class="formheader">meeting location</p> <?php echo $this->form->create(false); ?> <!--, array('url' => false)-->  <!-- array('action' => 'confirm'))); ?> --> <?php //echo $this->form->create(false, array('url' => array('action' => 'index'))); ?> <?php $today = date('d')+1; ?> <?php $formmonth = date('m'); ?> <?php echo $this->form->input('name', array(  'label' => array('text' => 'name:  '))); ?> <span class="errormessage"> <?php //echo $this->validationerrors['contacts']['contactsaddress'][0];?></span> <?php echo $this->form->input('address', array( 'label' =>  array('text' => 'address of meeting:  '))); ?> <?php cakelog::write('debug', $this->validationerrors['contacts']['contactsaddress'][0]); ?>  

as can see have been trying lot of different things. have been trying figure out couple of weeks no progress.

i appreciate light shed on delimma

apparently 1 of significant factors having model name first attribute in form->create. since did not want post database used false mistakenly thought meant no sql update. once put model name first attribute worked documented. way validate no database put $usertable=false in model.

hope helps somebody.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -