grigri,

I appreciate the help.  The debug didn't really help,  but you got me
thinking about it a bit more logically.  I simply placed the
validation routines inside the "Search" model and validation started
working by using something like this:
 if (!empty($this->data)) {
                $this->Search->create($this->data['Search']);
                if ($this->Search->validates()) {


And I change my view form to:
<?php echo $form->create('Search', array('type' => 'post', 'action' =>
'search', 'id' => 'request-form')); ?>

With those changes, validation started working, so I really appreciate
the help.

As for my label elements, I have them in the live version, I just
wanted to make the code as simple as possible as well as shorter to
make it easier to read.

Thanks again!
Cake Fan




On Dec 19, 4:15 am, grigri <[EMAIL PROTECTED]> wrote:
> A good first step would be a debug($this->data) in the view.
>
> Chances are, since the "model name" you're passing to
> FormHelper::create() is called 'search' and the model you're trying to
> save the data into is called 'RegTag', it simply doesn't make any
> sense.
>
> If you insist on having different names in the form and the model,
> you'll need to tell the controller to perform the translation:
>
> class IndexController extends AppController {
>   function search() {
>     if (!empty($this->data)) {
>       $this->RegTag->create(array('RegTag' => $this->data['Search']));
>       if ($this->RegTag->validates()) {
>         // ...
>       }
>     }
>   }
>
> }
>
> If this is your problem, a quick debug of $this->data would have shown
> you right away. If it isn't, do one and post the dump here.
>
> Also, I know this is only temp code, but why are you not having any
> label elements in your form?
>
> On Dec 18, 9:44 pm, Cake Fan <[EMAIL PROTECTED]> wrote:
>
> > After doing some reading and looking at 1.2 validation, I thought I
> > had a pretty good understanding of the process.
>
> > However, let's say I wanted manually validate a bit of data coming
> > from a post using the standard model validation features.  Seems like
> > it should be fairly straightforward, but I can't seem to get the
> > result I'm going for.
>
> > Since I'm not doing a "save", I'm just doing a findAll() on a Model,
> > but I want it to validate prior to doing the findAll().
>
> > For instance (highly simplified):
>
> > :::MODEL:::
> > -----------------------------------------------------------------
> > <?php
> > class RegTag extends AppModel
> > {
> >     var $useTable = 'reg_tags';
>
> >     var $validate = array(
> >         'what' => 'alphaNumeric',
> >         'where' => 'alphaNumeric'
> >     );}
>
> > ?>
> > -----------------------------------------------------------------
>
> > :::CONTROLLER:::
> > -----------------------------------------------------------------
> > <?php
> > class IndexController extends AppController {
> >    var $name = 'Index';
> >     var $helpers = array('html', 'time', 'javascript', 'ajax');
> >     var $uses = array('RegTag');
>
> >     /** main action (starting point) **/
> >     function search ()
> >     {
> >         /** we have a search **/
> >         if ($this->RegTag->create($this->data) && 
> > $this->RegTag->validates()) {
>
> >              //do something
> >         } else {
> >             //error
> >         }
>
> >       }}
>
> > ?>
> > -----------------------------------------------------------------
>
> > :::VIEW:::
> > -----------------------------------------------------------------
> >     <?php echo $form->create('search', array('type' => 'post',
> > 'action' => 'search', 'id' => 'request-form')); ?>
> >         <?php echo $form->input('what', array('type' => 'text',
> > 'label' => false)); ?>
> >         <?php echo $form->error('what', 'Please enter what!'); ?>
> >         <?php echo $form->input('where', array('type' => 'text',
> > 'label' => false)); ?>
> >         <?php echo $form->error('where', 'Please Enter Where!'); ?>
> >     <?php echo $form->end('Search'); ?>
> > -----------------------------------------------------------------
>
> > Assuming that's the basics of the search, shouldn't validation be
> > working?  As of right now, it doesn't.  The 
> > [$this->RegTag->create($this->data) && $this->RegTag->validates()] check 
> > always
>
> > returns false, no matter what I enter into the form.
>
> > Any help would be greatly appreciated!
>
> > Cake Fan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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