Hi all,

I have Back and Next as two buttons in my view file. Which are used
for the navigation between the pages.
Now when i click on Next button It should do the page validation also.
I have put the code below. Please help me.

In campaign.php model page
var $validate = array(
            'brand' => array(
            'rule' => array('minLength', 1),
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Please enter a value for the Brand field'
            ),
            'product' => array(
            'rule' => array('minLength', 1),
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Please enter a value for the Product field'
            ),
            'media' => array(
            'rule' => array('minLength', 1),
            'required' => true,
            'allowEmpty' => false,
            'message' => 'Please ensure you have selected Activation
Media for this promotion'
            ),

      );
In the controller page
 function step_two(){
        //get all data from agencies table
        $agencies = $this->Agencie->find('all', array('fields' =>
'Agencie.name'));
        $this->set('agencies',$agencies);
        //get all data from media table
        $media = $this->Media->find('all');
        $this->set('media',$media);
    }
In the view file
<!-- in header part -->
<?php
   // validation error display
   if($form->isFieldError('User.brand')) e($form->error
         ('User.brand', null, array('class' => 'failure')));
   else if($form->isFieldError('User.product')) e($form->error
         ('User.product', null, array('class' => 'failure')));
   else if($form->isFieldError('User.media')) e($form->error
         ('User.media', null, array('class' => 'failure')));

?>
. . .
<?php echo $form->create('Campaign', array('action' => 'step_two'));?>
. . .
<td style="width:80%" align="right" colspan="2">
            <?php
                $link = $this->webroot . 'campaigns/step_one';
                echo $form->button('< Back', array('onclick' => 
"location.href='".
$link."'"));
                $link = $this->webroot . 'campaigns/step_three';
                echo $form->button('Next >', array('onclick' => 
"location.href='".
$link."'"));    ?>
        </td>
Thanks in Advance
Ambika

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to