Hi! I've been seraching for weeks how to do that but didn't find any
good answer. I mean I thought it was supposed to be easy to do that,
but not at all. Here's the thing, I have to ask the user to choose a
month interval so I can show the right data to him. Since it's not
related to any table I have on my database, I just did this (sorry
don't know how to put tags to format as a code):

<?php
echo $this->Form->create(false);
echo $this->Form->month('m1', null, array('monthNames' => false));
echo ' until ';
echo $this->Form->month('m2', null, array('monthNames' => false));
echo $this->Form->end('Choose');
?>

And then created a simple rule at the model (there's only a rule for
one field, for test purpose):

var $validate = array('m1' => array('rule' => 'notEmpty', 'required'
=> true, 'message' => 'Error!'));

Here's my controller:

        function choose_date ($id = null) {
                if (!empty($this->data)) {
                        $this->Frequency->set($this->data);
                        if ($this->Frequency->validates()) {
                                $fD = $this->data['m1']['month'].'/'.date('Y');
                                $tD = $this->data['m2']['month'].'/'.date('Y');
                                $this->Session->write('Frequency.fromDate', 
$fD);
                                $this->Session->write('Frequency.toDate', $tD);
                                $this->redirect(array('action' => 'view'));
                        }
                } else { $this->Session->write('Worker.id', $id); }
        }

So what happens is that it just freezes at the "choose_date" view,
doesn't matter if do or don't select anything on the list. How can I
validate it?  It's probably a simple task but it's getting me crazy!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to