Monday, April 25, 2011

Re: Validation for a complex form

Thanx that was it. I never expected that when you say, that empty
field is disabled that it doesn't work for the null .

Do you know how to pass array of values to rule, each time you make a
request. I have to check if data for my select box has been entered or
some other value ...

On Apr 25, 1:18 pm, Jeremy Burns | Class Outfit
<jeremybu...@classoutfit.com> wrote:
> Try adding 'required' => true to the validation for the field.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 25 Apr 2011, at 10:27, Miloš Vučinić wrote:
>
> > I think I found a bug in cakephp validation .. I just realized one of
> > my problems is this..
> > If you have a select box, but unpopulated yet because it needs to be
> > filled after click on some other item (e.g another select box) it
> > doesn't get passed as index in array in this->data
>
> > In my example the index 'omiljeniProf1' has never been shown in $this-
> >> data[] so the validation for it never took place.. I think it is a
> > bug, because, if I have a model, which clearly states that I have a
> > field 'omiljeniProf1' and that it must not be null, and in Model-
> >> save(this-data) it is not passed, it needs to show an error..
>
> > I will have to work around this by checking is it passed in my
> > controller.. But for that, I need to have a way to se if
> > data['omiljeniProf1']==null without generating an error when it
> > doesn't exist..
> > How to check this without an error ?
>
> > All the best,
> > Milos
>
> > On Apr 25, 10:15 am, Miloš Vučinić <milosvuci...@gmail.com> wrote:
> >> Also validation for this select box has completely failed, because,
> >> that select box was empty, meaning with no data in it, and on submit
> >> it passed..
>
> >> Thanks,
> >> Milos
>
> >> On Apr 25, 10:07 am, Miloš Vučinić <milosvuci...@gmail.com> wrote:
>
> >>> Hi , thanks for helping.
>
> >>> My validation rule is, allow all Serbian utf-8 chars (I tried some
> >>> with utf codes but it didn't work so this works), dot, coma, and a
> >>> dash and none other chars. It looks like this.
>
> >>>         'omrazeniPorf1' => array(
> >>>                         'notempty' => array(
> >>>                                 'rule' => '/^[a-z0-9\.\,ŽžĐđŠšĆćČčабвгдђежзијклљмнњопрстћуфхцчћџШ\-
> >>> АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ\- ]{1,}$/i',
> >>>                                 'message' => 'Morate uneti ime profesora',
> >>>                                 'allowEmpty' => false,
> >>>                                 //'required' => false,
> >>>                                 //'last' => false, // Stop validation after this rule
> >>>                                 //'on' => 'create', // Limit validation to 'create' or 'update'
> >>> operations
> >>>                         ),
> >>>                 ),
>
> >>> View for this concrete field is in my code like this it is a select
> >>> box with size 5 :
> >>> <?php
> >>>                                 echo $this->Form->input('omiljeniProf1' , array('size'=>'5',
> >>> 'type'=>'select','label' => '5.a) Ime prvog profesora
> >>> ','onchange'=>'filltext(this,"mytext","PollAddForm")','style' =>
> >>> 'width:200px'));
> >>> ?>
>
> >>> where 'omiljeniProf1' is the name of the field, and onchange is a
> >>> function I wrote to automatically fill in some other text field..
>
> >>> Thanx
>
> >>> On Apr 24, 12:16 pm, acl68 <c...@anjaliebermann.de> wrote:
>
> >>>> Hi Milos,
>
> >>>> can you post the validation rules for this checkboxes and radio buttons?
>
> >>>> Anja
>
> >>>> Am Sonntag, 24. April 2011, um 10:41:55 schrieb Miloš Vučinić:
>
> >>>>> Hi,
>
> >>>>> I have a form which has many select boxes as well as many radio
> >>>>> groups. The problem I'm having is that when I validate the data in the
> >>>>> model, I receive general error If some data is not entered, but it is
> >>>>> not shown under the radio button group or near a select box item.
>
> >>>>> If I place a regular input text field , the validation message is show
> >>>>> correctly.
>
> >>>>> Can anyone help me with this ? Did anyone experience similar
> >>>>> problems ?
>
> >>>>> All the best,
> >>>>> Milos Vucinic
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

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

No comments: