Sunday, February 28, 2010

Re: custom Validation - message not shown

hmmm .... I created the view using the bake shell ; cake 1.3ß used to
be most up-to-date ... so it is some 'original' code
and as I wrote, if I use a built in validation the error message is
shown....

On 28 Feb., 17:48, John Andersen <j.andersen...@gmail.com> wrote:
> Hmm I don't actually see anything wrong with your validation
> definition and function. But I wonder about your view!! As far as the
> CakePHP book states, you should use the FormHelper using the $form
> object in the view! I have no idea whether that could be the reason,
> but have you tried to conform to the CakePHP way, by using $form
> instead of $this->Form ...?
>
> If you try it, do tell!
>    John
>
> On Feb 28, 6:29 pm, mivogt-LU <c...@mivogt.net> wrote:
>
> > Hi John,
>
> > I had a lokoup to the view code in the browser ... the message is not
> > contained in html code
>
> > some of the model code:
> > <?php
> > class BookingPosition extends AppModel {
> >         var $name = 'BookingPosition';
> >         var $displayField = 'id';
> >         //The Associations below have been created with all possible keys,
> > those that are not needed can be removed
>
> > //  var $validate = array(  'Lodging' => array(  'rule' =>
> > array('limitBelegung', 2, 99,99,99),  'message' => 'Das Zimmer ist
> > überbucht!!' ) );
> > //  var $validate  =array('Lodging' => array ('limitBelegung' =>
> > array('rule'=>'limitBelegung', 'message'=>'naja')));
>
> > //$a=debug($data);
>
> > var $validate=array
> > (
> > 'AnzahlErwachsene' =>        array('rule'=>'limitPersonen','message'=>'das
> > sind zu viele für das Bett'),
> > 'AnzahlJugendliche' =>       array('rule'=>'limitPersonen','message'=>'das
> > sind zu viele für das Bett'),
> > 'AnzahlKinder' =>            array('rule'=>'limitPersonen','message'=>'das sind
> > zu viele für das Bett')
> > );
>
> > .... ... ....
>
> >  function limitPersonen()
> >   {
> >         $E = $this->data['BookingPosition']['AnzahlErwachsene'];
> >         $J = $this->data['BookingPosition']['AnzahlJugendliche'];
> >         $K = $this->data['BookingPosition']['AnzahlKinder'];
>
> >        // $A = $this->query("SELECT Bettenanzahl FROM Lodgings WHERE
> > id=" . $this->data['BookingPosition']['lodging_id'] );
> >        // $max = (int)$A[0]['Lodgings']['Bettenanzahl'];
> >        // $numberOfBeds =(int)$max;
>
> >                 $Y1=$this->Lodging->find('first',array('conditions'=>array('Lodging.id'=>$this-
> > >data['BookingPosition']['lodging_id'])));
>
> >                 //debug($Y1);
> >         $numberOfBeds   =(int)$Y1['Lodging']['Bettenanzahl'];
>
> >                 echo $numberOfBeds      ;
>
> >         $X = (int)$E + (int)$J + (int)$K;
> >        return ((int)$X <= $numberOfBeds) ; //($AnzE + $AnzJ + $AnzK)<
> > $maxAnz;
> >   }
> > .... .... ....
> > and the view code for add is like this:
> > <div class="bookingPositions form">
> > <?php echo $this->Form->create('BookingPosition');?>
> >         <fieldset>
> >                 <legend><?php printf(__('Add %s', true), __('Booking Position',
> > true)); ?></legend>
> >         <?php
> >                 echo $this->Form->input('booking_id');
> >                 echo $this->Form->input('AnreiseDatum');
> >                 echo $this->Form->input('AbreiseDatum');
> >                 echo $this->Form->input('bookingstatus_id');
> >                 echo $this->Form->input('lodging_id');
> >                  // debug($this->data);
> >                 echo $this->Form->input('meal_id');
> >                 echo $this->Form->input('room_id');
> >                 echo $this->Form->input('material_id');
> >                 echo $this->Form->input('AnzahlErwachsene');
> >                 echo $this->Form->input('AnzahlJugendliche');
> >                 echo $this->Form->input('AnzahlKinder');
> >         ?>
> >         </fieldset>
> > <?php echo $this->Form->end(__('Submit', true));?>
> > </div>
>
> > so I have no idea why my message is not shown, but if i use a built in
> > one like requiered/notempty the message is shown.
>
> > Any hint so far?
>
> > TIA
>
> > Michael
>
> > On 28 Feb., 09:20, John Andersen <j.andersen...@gmail.com> wrote:
>
> > > Try to look at the source in the browser, maybe your CSS has limited
> > > the height of the DIV so that you message is not shown below the INPUT
> > > field!
>
> > > If that is not the case, please show your code for the view in which
> > > the errors should be displayed!
> > > Enjoy,
> > >    John
>
> > > On Feb 28, 12:51 am, mivogt-LU <c...@mivogt.net> wrote:
>
> > > > [cake 1.3ß | XAMPP 1.7.3|PHP 5.3.1|MySQL 5.1.41 | Win XP SP3]
>
> > > > Hi everybody,
>
> > > > I just has a little problem with my error-message in a custom
> > > > validation function.
> > > > If I use the built in functions like required the message is shown so
> > > > css and div seem to be ok
> > > > If I use my own function there is a red bar below the validated field
> > > > but no error message below it.
>
> > > > I call the validation like this:
> > > > var $validate=array
> > > > (
> > > > 'AnzahlErwachsene' =>        array('rule'=>'limitPersonen','message'=>'das
> > > > sind zu viele für das Bett'),
> > > > 'AnzahlJugendliche' =>       array('rule'=>'limitPersonen','message'=>'das
> > > > sind zu viele für das Bett'),
> > > > 'AnzahlKinder' =>            array('rule'=>'limitPersonen','message'=>'das sind
> > > > zu viele für das Bett')
> > > > );
>
> > > > The function itselfe just returns a true or false depending on a
> > > > numerical checkup.
> > > > The funciton works fine so far - but I miss my message (see above)
>
> > > > Is there someone who might tell me why I miss the message text?
>
> > > > Thanks in advance
>
> > > > Michael
>
> > > > [cake 1.3ß | XAMPP 1.7.3|PHP 5.3.1|MySQL 5.1.41 | Win XP SP3]

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: