Hi Jeremy,

I did the corrections for minlength and I put <?php debug($this-
>data);?> code both in controller and view.
When i submit the form with some empty fields, then error msg is
displaying and in the controller i am getting the data but not in the
view file.

Ambika

On Apr 9, 10:51 am, Jeremy Burns <jeremybu...@me.com> wrote:
> A few quick observations...
>
> Your 'minLenght' validation rules are spelt incorrectly. Should be 
> 'minLength'.
>
> Try using <code> echo $this->Form->input('Model.fieldName', array('class' => 
> 'fullwidth')); </code>. Notice I use the model name as well.
>
> This ought to make your $form-error statements redundant too.
>
> Next step is to: <code> debug($this->data); </code> ...in both your 
> controller function and your view - see what's in there. If you are still 
> having problems, post the contents of the data array back here.
>
> Jeremy Burns
> jeremybu...@me.com
>
> On 9 Apr 2010, at 06:42, Ambika Kulkarni wrote:
>
> > Hi John,
>
> > In the model(user.php) I am doing the validation
> > <?php
> > class User extends AppModel {
> >   var $name = 'User';
> >   var $validate = array(
> >   'name' => array(
> >      'rule' => array('minLenght', 1),
> >      'required' => true,
> >      'allowEmpty' => false,
> >      'message' => 'Please enter a value for the Name field'
> >   ),
> >    'telephone' => array(
> >      'rule' => array('minLenght', 1),
> >      'required' => true,
> >      'allowEmpty' => false,
> >      'message' => 'Please enter a value for the Telephone field'
> >   ),
> >    'email' => array(
> >      'rule' => 'email',
> >      'required' => true,
> >      'allowEmpty' => false,
> >      'message' => 'Please enter a value for the Email field'
> >   ),
> >   'username' => array(
> >      'rule' => array('minLenght', 1),
> >      'required' => true,
> >      'allowEmpty' => false,
> >      'message' => 'Please enter a user name'
> >   ),
> >   'password' => array(
> >      'rule' => array('minLenght', 1),
> >      'required' => true,
> >      'allowEmpty' => false,
> >      'message' => 'Please enter a password'
> >   ),
>
> > );
> > }
> > ?>
> > In the users_controller.php
> > <?php
> > class UsersController extends AppController {
> >   var $name = 'Users';
> >   var $components = array('Auth');
> >   function register(){
> >   if (!empty($this->data)) {
> >      if(isset($this->data['User']['password2']))
> >         $this->data['User']['password2hashed'] = $this->
> >             Auth->password($this->data['User']['password2']);
> >      $this->User->create();
> >      if ($this->User->save($this->data)) {
> >         $this->Session->setFlash('Congratulations! You have signed
> > up!');
> >       } else {
> >         $this->Session->setFlash('There was an error signing up.
> > Please, try again.');
> >         $this->data = null;
> >      }
> >   }
> > }
> >   function login() {}
> >   function logout() {
> >      $this->Session->setFlash('Logout');
> >      $this->redirect($this->Auth->logout());
> >   }
> > }
> > ?>
> > And in the register.ctp file
> > for error message display
> > <?php
> >   // validation error display
> >   if($form->isFieldError('User.name')) e($form->error
> >         ('User.name', null, array('class' => 'failure')));
> >   else if($form->isFieldError('User.telephone')) e($form->error
> >         ('User.telephone', null, array('class' => 'failure')));
> >   else if($form->isFieldError('User.email')) e($form->error
> >         ('User.email', null, array('class' => 'failure')));
> >   else if($form->isFieldError('User.username')) e($form->error
> >         ('User.username', null, array('class' => 'failure')));
> > ?>
>
> > n this is my form
> > <?php e($form->create('User', array('action' => 'register')));?>
> > <table width="100%" cellpadding="0" cellspacing="3" border="0"
> > class="form_text">
>
> >    <!--Contact Details Start-->
>
> >    <tr>
>
> >            <td width="250" align="right">Firstname&nbsp;</td>
> >            <td width="1338"><?php e($form->text('name', array('class'=>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Lastname&nbsp;</td>
> >            <td width="1338"> <?php e($form->text('surname', array('class' =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Contact Number&nbsp;</td>
> >            <td width="1338"> <?php e($form->text('telephone', array('class' 
> > =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Fax&nbsp;</td>
> >            <td width="1338"> <?php e($form->text('fax', array('class' =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Email&nbsp;</td>
> >            <td width="1338"> <?php e($form->text('email', array('class' =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Postal Address&nbsp;</td>
> >            <td> <?php e($form->text('address1', array('class' =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right"></td>
> >            <td width="1338"> <?php e($form->text('address2', array('class' 
> > =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right"></td>
> >            <td> <?php e($form->text('address3', array('class' =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right"></td>
> >            <td> <?php e($form->text('postal_code', array('class' =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Username&nbsp;</td>
> >            <td width="1338"> <?php e($form->text('username', array('class' 
> > =>
> > 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Password&nbsp;</td>
> >            <td width="1338"> <?php e($form->password('password', 
> > array('class'
> > => 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td width="250" align="right">Confirm Password&nbsp;</td>
> >            <td width="1338"> <?php e($form->password('cpassword', 
> > array('class'
> > => 'fullwidth'))); ?></td>
> >    </tr>
> >    <tr>
> >            <td colspan="2">&nbsp;</td>
> >    </tr>
>
> >    <tr>
> >            <td></td>
> >            <td colspan="2" align="left"> <?php e($form->submit('Save',
> > array('div' => false,'class' => 'submitbutton'))); ?></td>
> >    </tr>
> >    <!--Contact Details End-->
> > </table>
> > <?php e($form->end()); ?>
>
> > I hope this much of information is enough
>
> > When I click on Save button, it does the validation n prompts the
> > relevent error msg. But If I have alerady filled some other fileds
> > their value gets cleared.
>
> > For Eg: I have entered all fields but the email field is not in the
> > required format, then it prompts the error msg, after that all fields
> > gets cleared.
>
> > I hope u understood want i am saying
>
> > Thanks
>
> > On Apr 8, 6:41 pm, John Andersen <j.andersen...@gmail.com> wrote:
> >> Please provide more information:
> >> 1) What are you doing with the data in $this->data before and after
> >> validation?
> >> 2) Are you doing other processing of $this->data in beforeFilter
> >> function?
> >> 3) How does the data structure look like before validation and after?
> >> (use debug!)
>
> >> With the above we may better be able to help you on the way :)
> >> Enjoy,
> >>    John
>
> >> On Apr 8, 4:03 pm, Ambika Kulkarni <ambikakulkarn...@gmail.com> wrote:
>
> >>> Hi all,
>
> >>> After validation the data from the filed is disappearing. How to
> >>> restore the values of the field.
> >>> I am using
> >>> <?php e($form->text('name', array('class'=> 'fullwidth'))); ?> tag for
> >>> creating fields.
>
> >>> Thanks in advance
> >>> Ambika
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups 
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> > To unsubscribe, reply using "remove me" as the subject.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to