Re: select box validation in CakaPHP 1.2
Even "manual" invalidation doesn't help: $this->ModelName->invalidate('field_name', 'error_message'); doesn't display error_message in layout :-/ On Nov 1, 9:30 am, senser <[EMAIL PROTECTED]> wrote: > Doesn't anybody validate select_boxes? > How do you render error_messages? > > On Oct 22, 8:10 am, senser <[EMAIL PROTECTED]> wrote: > > > Hi Japheth, > > > The problem is that if I use 'selected'=>'' and when form doesn't > > validate because wrong fields the application "doesn't remember" the > > selected value in listbox. For example if user selects 2001-2002 tax > > year and submit form with wrong field for tax, form doesn't validate > > and remember the entered value for tax, but doesn't remember the > > selected tax year because of using 'selected'=>'' > > > On Oct 21, 10:46 am, Japheth <[EMAIL PROTECTED]> wrote: > > > > Hi Senser, > > > > I've managed to use showEmpty => ' ', to provide an option that is > > > essentially blank. You could then use trim() if you found that ' ' > > > still was counted as a value? > > > Also, if you want to make sure that the empty option is selected by > > > default, you could add 'selected' => ' ' to your options array also. > > > > Does that make sense? If so, did it help? > > > > Cheers, > > > Japheth > > > > On Oct 20, 9:00 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > I found this link while searching for resolve but it didn't help - > > > > when I use "array(showEmpty=>'Select...')" it shows inselectboxbut > > > > it's not selected by default and doesn't help :( > > > > > May beselectboxes must be validated in different manner but I don't > > > > know how > > > > > On Oct 20, 12:22 pm, manuj bansal <[EMAIL PROTECTED]> wrote: > > > > > > your problem may be solved by this link > > > > > >http://groups.google.com/group/cake-php/browse_thread/thread/8c89ca42... > > > > > > On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > > > Hi manuj. > > > > > > > Your proposal didn't solve my problem. I think I did read somewhere > > > > > > in > > > > > > group postings that using fromHelpr->input is the right way for form > > > > > > fields and using formHelper->select, formHelper->label, ... etc will > > > > > > be deprecated in next versions of CakePHP. I'm not sure for this and > > > > > > correct me if I'm wrong. > > > > > > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > > > > > i didnt get your code you wantselectoption then why r you going > > > > > > > thru > > > > > > > input function > > > > > > > > try it > > > > > > > > *view code > > > > > > > > echo $form->label('modelname.name') > > > > > > > echo $form->select('modelname.name',array('value'=>'text')); > > > > > > > echo $form->error('it can't be blank'); > > > > > > > > ***model code* > > > > > > > > var > > > > > > > $validate=array('name'=>VALID_NOT_EMPTY); > > > > > > > > IT IS FORSELECTOPTION > > > > > > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > > > > > Hi there! > > > > > > > > > I'm trying to write a code for displaying aselectboxwith several > > > > > > > > options (tax years for example) and I have to validate the data > > > > > > > > passed > > > > > > > > by thatselectbox. I want the user to mustselectan option from > > > > > > > > the > > > > > > > > list. > > > > > > > > Here is the code from view file where I populate theboxusing > > > > > > > > formHelper: > > > > > > > > > /CODE**/ > > > > > > > > print $form->input('CustomerTaxYear.tax_years_id', > > > > > > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > > > > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year > > > > > > > > is > > > > > > > > obligatory', 'maxlength'=>'Tax year code max length is 3 > > > > > > > > symbols', > > > > > > > > 'number'=>'Tax year code must be a number'))); > > > > > > > > /CODE_END/ > > > > > > > > > and here is the part ofvalidationarray: > > > > > > > > > /CODE**/ > > > > > > > > var > > > > > > > > $validate=array( > > > > > > > > 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > > > > > > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > > > > > > > > > > > 'number'=>VALID_NUMBER)); > > > > > > > > /CODE_END/ > > > > > > > > > The result is that if the user doesn'tselectan element from the > > > > > > > >selectbox, there is no error message displayed and > > > > > > > >thevalidationis > > > > > > > > passed but the form data is not stored in DB, because the field > > > > > > > > "tax_years_id" doesn't have default value which is correct > > > > > > > > behaviour. > > > > > > > > > I've tried with 'show
Re: select box validation in CakaPHP 1.2
Doesn't anybody validate select_boxes? How do you render error_messages? On Oct 22, 8:10 am, senser <[EMAIL PROTECTED]> wrote: > Hi Japheth, > > The problem is that if I use 'selected'=>'' and when form doesn't > validate because wrong fields the application "doesn't remember" the > selected value in listbox. For example if user selects 2001-2002 tax > year and submit form with wrong field for tax, form doesn't validate > and remember the entered value for tax, but doesn't remember the > selected tax year because of using 'selected'=>'' > > On Oct 21, 10:46 am, Japheth <[EMAIL PROTECTED]> wrote: > > > Hi Senser, > > > I've managed to use showEmpty => ' ', to provide an option that is > > essentially blank. You could then use trim() if you found that ' ' > > still was counted as a value? > > Also, if you want to make sure that the empty option is selected by > > default, you could add 'selected' => ' ' to your options array also. > > > Does that make sense? If so, did it help? > > > Cheers, > > Japheth > > > On Oct 20, 9:00 pm, senser <[EMAIL PROTECTED]> wrote: > > > > I found this link while searching for resolve but it didn't help - > > > when I use "array(showEmpty=>'Select...')" it shows inselectboxbut > > > it's not selected by default and doesn't help :( > > > > May beselectboxes must be validated in different manner but I don't > > > know how > > > > On Oct 20, 12:22 pm, manuj bansal <[EMAIL PROTECTED]> wrote: > > > > > your problem may be solved by this link > > > > >http://groups.google.com/group/cake-php/browse_thread/thread/8c89ca42... > > > > > On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > > Hi manuj. > > > > > > Your proposal didn't solve my problem. I think I did read somewhere in > > > > > group postings that using fromHelpr->input is the right way for form > > > > > fields and using formHelper->select, formHelper->label, ... etc will > > > > > be deprecated in next versions of CakePHP. I'm not sure for this and > > > > > correct me if I'm wrong. > > > > > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > > > > i didnt get your code you wantselectoption then why r you going thru > > > > > > input function > > > > > > > try it > > > > > > > *view code > > > > > > > echo $form->label('modelname.name') > > > > > > echo $form->select('modelname.name',array('value'=>'text')); > > > > > > echo $form->error('it can't be blank'); > > > > > > > ***model code* > > > > > > > var > > > > > > $validate=array('name'=>VALID_NOT_EMPTY); > > > > > > > IT IS FORSELECTOPTION > > > > > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > > > > Hi there! > > > > > > > > I'm trying to write a code for displaying aselectboxwith several > > > > > > > options (tax years for example) and I have to validate the data > > > > > > > passed > > > > > > > by thatselectbox. I want the user to mustselectan option from the > > > > > > > list. > > > > > > > Here is the code from view file where I populate theboxusing > > > > > > > formHelper: > > > > > > > > /CODE**/ > > > > > > > print $form->input('CustomerTaxYear.tax_years_id', > > > > > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > > > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > > > > > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > > > > > > 'number'=>'Tax year code must be a number'))); > > > > > > > /CODE_END/ > > > > > > > > and here is the part ofvalidationarray: > > > > > > > > /CODE**/ > > > > > > > var > > > > > > > $validate=array( > > > > > > > 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > > > > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > > > > > > > > > 'number'=>VALID_NUMBER)); > > > > > > > /CODE_END/ > > > > > > > > The result is that if the user doesn'tselectan element from the > > > > > > >selectbox, there is no error message displayed and thevalidationis > > > > > > > passed but the form data is not stored in DB, because the field > > > > > > > "tax_years_id" doesn't have default value which is correct > > > > > > > behaviour. > > > > > > > > I've tried with 'showEmpty' set to true but with no success. If > > > > > > > there > > > > > > > is no value selected inselectbox, the passed array doesn't even > > > > > > > have > > > > > > > an a element called 'tax_years_id'. (i make a dump of $this->data > > > > > > > and > > > > > > > in the array element with name 'tax_years_id' is missing). I've > > > > > > > also > > > > > > > tried to make an empty element andselectit by default, but I think > > > > > > > this
Re: select box validation in CakaPHP 1.2
Hi Japheth, The problem is that if I use 'selected'=>'' and when form doesn't validate because wrong fields the application "doesn't remember" the selected value in list box. For example if user selects 2001-2002 tax year and submit form with wrong field for tax, form doesn't validate and remember the entered value for tax, but doesn't remember the selected tax year because of using 'selected'=>'' On Oct 21, 10:46 am, Japheth <[EMAIL PROTECTED]> wrote: > Hi Senser, > > I've managed to use showEmpty => ' ', to provide an option that is > essentially blank. You could then use trim() if you found that ' ' > still was counted as a value? > Also, if you want to make sure that the empty option is selected by > default, you could add 'selected' => ' ' to your options array also. > > Does that make sense? If so, did it help? > > Cheers, > Japheth > > On Oct 20, 9:00 pm, senser <[EMAIL PROTECTED]> wrote: > > > I found this link while searching for resolve but it didn't help - > > when I use "array(showEmpty=>'Select ...')" it shows in select box but > > it's not selected by default and doesn't help :( > > > May be select boxes must be validated in different manner but I don't > > know how > > > On Oct 20, 12:22 pm, manuj bansal <[EMAIL PROTECTED]> wrote: > > > > your problem may be solved by this link > > > >http://groups.google.com/group/cake-php/browse_thread/thread/8c89ca42... > > > > On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > Hi manuj. > > > > > Your proposal didn't solve my problem. I think I did read somewhere in > > > > group postings that using fromHelpr->input is the right way for form > > > > fields and using formHelper->select, formHelper->label, ... etc will > > > > be deprecated in next versions of CakePHP. I'm not sure for this and > > > > correct me if I'm wrong. > > > > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > > > i didnt get your code you want select option then why r you going thru > > > > > input function > > > > > > try it > > > > > > *view code > > > > > > echo $form->label('modelname.name') > > > > > echo $form->select('modelname.name',array('value'=>'text')); > > > > > echo $form->error('it can't be blank'); > > > > > > ***model code* > > > > > > var > > > > > $validate=array('name'=>VALID_NOT_EMPTY); > > > > > > IT IS FOR SELECT OPTION > > > > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > > > Hi there! > > > > > > > I'm trying to write a code for displaying a select box with several > > > > > > options (tax years for example) and I have to validate the data > > > > > > passed > > > > > > by that select box. I want the user to must select an option from > > > > > > the > > > > > > list. > > > > > > Here is the code from view file where I populate the box using > > > > > > formHelper: > > > > > > > /CODE**/ > > > > > > print $form->input('CustomerTaxYear.tax_years_id', > > > > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > > > > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > > > > > 'number'=>'Tax year code must be a number'))); > > > > > > /CODE_END/ > > > > > > > and here is the part of validation array: > > > > > > > /CODE**/ > > > > > > var > > > > > > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > > > > > > > 'number'=>VALID_NUMBER)); > > > > > > /CODE_END/ > > > > > > > The result is that if the user doesn't select an element from the > > > > > > select box, there is no error message displayed and the validation > > > > > > is > > > > > > passed but the form data is not stored in DB, because the field > > > > > > "tax_years_id" doesn't have default value which is correct > > > > > > behaviour. > > > > > > > I've tried with 'showEmpty' set to true but with no success. If > > > > > > there > > > > > > is no value selected in select box, the passed array doesn't even > > > > > > have > > > > > > an a element called 'tax_years_id'. (i make a dump of $this->data > > > > > > and > > > > > > in the array element with name 'tax_years_id' is missing). I've also > > > > > > tried to make an empty element and select it by default, but I think > > > > > > this is "ugly" approach, because if user selects some tax year but > > > > > > form validation fails by reason of other wrong filled field and > > > > > > selected element in tax year select box is lost.- Hide quoted text - > > > > > - Show quoted text - --~--~-~--~-
Re: select box validation in CakaPHP 1.2
Hi Senser, I've managed to use showEmpty => ' ', to provide an option that is essentially blank. You could then use trim() if you found that ' ' still was counted as a value? Also, if you want to make sure that the empty option is selected by default, you could add 'selected' => ' ' to your options array also. Does that make sense? If so, did it help? Cheers, Japheth On Oct 20, 9:00 pm, senser <[EMAIL PROTECTED]> wrote: > I found this link while searching for resolve but it didn't help - > when I use "array(showEmpty=>'Select ...')" it shows in select box but > it's not selected by default and doesn't help :( > > May be select boxes must be validated in different manner but I don't > know how > > On Oct 20, 12:22 pm, manuj bansal <[EMAIL PROTECTED]> wrote: > > > your problem may be solved by this link > > >http://groups.google.com/group/cake-php/browse_thread/thread/8c89ca42... > > > On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > > > > Hi manuj. > > > > Your proposal didn't solve my problem. I think I did read somewhere in > > > group postings that using fromHelpr->input is the right way for form > > > fields and using formHelper->select, formHelper->label, ... etc will > > > be deprecated in next versions of CakePHP. I'm not sure for this and > > > correct me if I'm wrong. > > > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > > i didnt get your code you want select option then why r you going thru > > > > input function > > > > > try it > > > > > *view code > > > > > echo $form->label('modelname.name') > > > > echo $form->select('modelname.name',array('value'=>'text')); > > > > echo $form->error('it can't be blank'); > > > > > ***model code* > > > > > var > > > > $validate=array('name'=>VALID_NOT_EMPTY); > > > > > IT IS FOR SELECT OPTION > > > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > > Hi there! > > > > > > I'm trying to write a code for displaying a select box with several > > > > > options (tax years for example) and I have to validate the data passed > > > > > by that select box. I want the user to must select an option from the > > > > > list. > > > > > Here is the code from view file where I populate the box using > > > > > formHelper: > > > > > > /CODE**/ > > > > > print $form->input('CustomerTaxYear.tax_years_id', > > > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > > > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > > > > 'number'=>'Tax year code must be a number'))); > > > > > /CODE_END/ > > > > > > and here is the part of validation array: > > > > > > /CODE**/ > > > > > var > > > > > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > > > > > 'number'=>VALID_NUMBER)); > > > > > /CODE_END/ > > > > > > The result is that if the user doesn't select an element from the > > > > > select box, there is no error message displayed and the validation is > > > > > passed but the form data is not stored in DB, because the field > > > > > "tax_years_id" doesn't have default value which is correct behaviour. > > > > > > I've tried with 'showEmpty' set to true but with no success. If there > > > > > is no value selected in select box, the passed array doesn't even have > > > > > an a element called 'tax_years_id'. (i make a dump of $this->data and > > > > > in the array element with name 'tax_years_id' is missing). I've also > > > > > tried to make an empty element and select it by default, but I think > > > > > this is "ugly" approach, because if user selects some tax year but > > > > > form validation fails by reason of other wrong filled field and > > > > > selected element in tax year select box is lost.- Hide quoted text - > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: select box validation in CakaPHP 1.2
I found this link while searching for resolve but it didn't help - when I use "array(showEmpty=>'Select ...')" it shows in select box but it's not selected by default and doesn't help :( May be select boxes must be validated in different manner but I don't know how On Oct 20, 12:22 pm, manuj bansal <[EMAIL PROTECTED]> wrote: > your problem may be solved by this link > > http://groups.google.com/group/cake-php/browse_thread/thread/8c89ca42... > > On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > > > Hi manuj. > > > Your proposal didn't solve my problem. I think I did read somewhere in > > group postings that using fromHelpr->input is the right way for form > > fields and using formHelper->select, formHelper->label, ... etc will > > be deprecated in next versions of CakePHP. I'm not sure for this and > > correct me if I'm wrong. > > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > i didnt get your code you want select option then why r you going thru > > > input function > > > > try it > > > > *view code > > > > echo $form->label('modelname.name') > > > echo $form->select('modelname.name',array('value'=>'text')); > > > echo $form->error('it can't be blank'); > > > > ***model code* > > > > var > > > $validate=array('name'=>VALID_NOT_EMPTY); > > > > IT IS FOR SELECT OPTION > > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > > Hi there! > > > > > I'm trying to write a code for displaying a select box with several > > > > options (tax years for example) and I have to validate the data passed > > > > by that select box. I want the user to must select an option from the > > > > list. > > > > Here is the code from view file where I populate the box using > > > > formHelper: > > > > > /CODE**/ > > > > print $form->input('CustomerTaxYear.tax_years_id', > > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > > > 'number'=>'Tax year code must be a number'))); > > > > /CODE_END/ > > > > > and here is the part of validation array: > > > > > /CODE**/ > > > > var > > > > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > > > 'number'=>VALID_NUMBER)); > > > > /CODE_END/ > > > > > The result is that if the user doesn't select an element from the > > > > select box, there is no error message displayed and the validation is > > > > passed but the form data is not stored in DB, because the field > > > > "tax_years_id" doesn't have default value which is correct behaviour. > > > > > I've tried with 'showEmpty' set to true but with no success. If there > > > > is no value selected in select box, the passed array doesn't even have > > > > an a element called 'tax_years_id'. (i make a dump of $this->data and > > > > in the array element with name 'tax_years_id' is missing). I've also > > > > tried to make an empty element and select it by default, but I think > > > > this is "ugly" approach, because if user selects some tax year but > > > > form validation fails by reason of other wrong filled field and > > > > selected element in tax year select box is lost.- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: select box validation in CakaPHP 1.2
your problem may be solved by this link http://groups.google.com/group/cake-php/browse_thread/thread/8c89ca42d68496a0/89e2724d53aaad65?lnk=gst&q=select+box+validation#89e2724d53aaad65 On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > Hi manuj. > > Your proposal didn't solve my problem. I think I did read somewhere in > group postings that using fromHelpr->input is the right way for form > fields and using formHelper->select, formHelper->label, ... etc will > be deprecated in next versions of CakePHP. I'm not sure for this and > correct me if I'm wrong. > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > > i didnt get your code you want select option then why r you going thru > > input function > > > try it > > > *view code > > > echo $form->label('modelname.name') > > echo $form->select('modelname.name',array('value'=>'text')); > > echo $form->error('it can't be blank'); > > > ***model code* > > > var > > $validate=array('name'=>VALID_NOT_EMPTY); > > > IT IS FOR SELECT OPTION > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > Hi there! > > > > I'm trying to write a code for displaying a select box with several > > > options (tax years for example) and I have to validate the data passed > > > by that select box. I want the user to must select an option from the > > > list. > > > Here is the code from view file where I populate the box using > > > formHelper: > > > > /CODE**/ > > > print $form->input('CustomerTaxYear.tax_years_id', > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > > 'number'=>'Tax year code must be a number'))); > > > /CODE_END/ > > > > and here is the part of validation array: > > > > /CODE**/ > > > var > > > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > 'number'=>VALID_NUMBER)); > > > /CODE_END/ > > > > The result is that if the user doesn't select an element from the > > > select box, there is no error message displayed and the validation is > > > passed but the form data is not stored in DB, because the field > > > "tax_years_id" doesn't have default value which is correct behaviour. > > > > I've tried with 'showEmpty' set to true but with no success. If there > > > is no value selected in select box, the passed array doesn't even have > > > an a element called 'tax_years_id'. (i make a dump of $this->data and > > > in the array element with name 'tax_years_id' is missing). I've also > > > tried to make an empty element and select it by default, but I think > > > this is "ugly" approach, because if user selects some tax year but > > > form validation fails by reason of other wrong filled field and > > > selected element in tax year select box is lost.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: select box validation in CakaPHP 1.2
thanks for info i am not sure about it as mannual, it looks they remove $html->submit but they didn't mention their about $form->submit will be depreceated On Oct 20, 12:50 pm, senser <[EMAIL PROTECTED]> wrote: > Hi manuj. > > Your proposal didn't solve my problem. I think I did read somewhere in > group postings that using fromHelpr->input is the right way for form > fields and using formHelper->select, formHelper->label, ... etc will > be deprecated in next versions of CakePHP. I'm not sure for this and > correct me if I'm wrong. > > On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > > > > > i didnt get your code you want select option then why r you going thru > > input function > > > try it > > > *view code > > > echo $form->label('modelname.name') > > echo $form->select('modelname.name',array('value'=>'text')); > > echo $form->error('it can't be blank'); > > > ***model code* > > > var > > $validate=array('name'=>VALID_NOT_EMPTY); > > > IT IS FOR SELECT OPTION > > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > > Hi there! > > > > I'm trying to write a code for displaying a select box with several > > > options (tax years for example) and I have to validate the data passed > > > by that select box. I want the user to must select an option from the > > > list. > > > Here is the code from view file where I populate the box using > > > formHelper: > > > > /CODE**/ > > > print $form->input('CustomerTaxYear.tax_years_id', > > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > > 'number'=>'Tax year code must be a number'))); > > > /CODE_END/ > > > > and here is the part of validation array: > > > > /CODE**/ > > > var > > > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > > > 'number'=>VALID_NUMBER)); > > > /CODE_END/ > > > > The result is that if the user doesn't select an element from the > > > select box, there is no error message displayed and the validation is > > > passed but the form data is not stored in DB, because the field > > > "tax_years_id" doesn't have default value which is correct behaviour. > > > > I've tried with 'showEmpty' set to true but with no success. If there > > > is no value selected in select box, the passed array doesn't even have > > > an a element called 'tax_years_id'. (i make a dump of $this->data and > > > in the array element with name 'tax_years_id' is missing). I've also > > > tried to make an empty element and select it by default, but I think > > > this is "ugly" approach, because if user selects some tax year but > > > form validation fails by reason of other wrong filled field and > > > selected element in tax year select box is lost.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: select box validation in CakaPHP 1.2
Hi manuj. Your proposal didn't solve my problem. I think I did read somewhere in group postings that using fromHelpr->input is the right way for form fields and using formHelper->select, formHelper->label, ... etc will be deprecated in next versions of CakePHP. I'm not sure for this and correct me if I'm wrong. On Oct 19, 8:06 pm, manuj bansalr <[EMAIL PROTECTED]> wrote: > i didnt get your code you want select option then why r you going thru > input function > > try it > > *view code > > echo $form->label('modelname.name') > echo $form->select('modelname.name',array('value'=>'text')); > echo $form->error('it can't be blank'); > > ***model code* > > var > $validate=array('name'=>VALID_NOT_EMPTY); > > IT IS FOR SELECT OPTION > > On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > > > Hi there! > > > I'm trying to write a code for displaying a select box with several > > options (tax years for example) and I have to validate the data passed > > by that select box. I want the user to must select an option from the > > list. > > Here is the code from view file where I populate the box using > > formHelper: > > > /CODE**/ > > print $form->input('CustomerTaxYear.tax_years_id', > > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > > 'number'=>'Tax year code must be a number'))); > > /CODE_END/ > > > and here is the part of validation array: > > > /CODE**/ > > var > > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > > > 'maxlength'=>array('rule'=>array('between',1,3)), > > > > 'number'=>VALID_NUMBER)); > > /CODE_END/ > > > The result is that if the user doesn't select an element from the > > select box, there is no error message displayed and the validation is > > passed but the form data is not stored in DB, because the field > > "tax_years_id" doesn't have default value which is correct behaviour. > > > I've tried with 'showEmpty' set to true but with no success. If there > > is no value selected in select box, the passed array doesn't even have > > an a element called 'tax_years_id'. (i make a dump of $this->data and > > in the array element with name 'tax_years_id' is missing). I've also > > tried to make an empty element and select it by default, but I think > > this is "ugly" approach, because if user selects some tax year but > > form validation fails by reason of other wrong filled field and > > selected element in tax year select box is lost. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: select box validation in CakaPHP 1.2
i didnt get your code you want select option then why r you going thru input function try it *view code echo $form->label('modelname.name') echo $form->select('modelname.name',array('value'=>'text')); echo $form->error('it can't be blank'); ***model code* var $validate=array('name'=>VALID_NOT_EMPTY); IT IS FOR SELECT OPTION On Oct 19, 9:24 pm, senser <[EMAIL PROTECTED]> wrote: > Hi there! > > I'm trying to write a code for displaying a select box with several > options (tax years for example) and I have to validate the data passed > by that select box. I want the user to must select an option from the > list. > Here is the code from view file where I populate the box using > formHelper: > > /CODE**/ > print $form->input('CustomerTaxYear.tax_years_id', > array('type'=>'select', 'label'=>'Tax Year', 'options'=> > $taxYearsArray, 'size'=>3,'error'=>array('required'=>'Tax Year is > obligatory', 'maxlength'=>'Tax year code max length is 3 symbols', > 'number'=>'Tax year code must be a number'))); > /CODE_END/ > > and here is the part of validation array: > > /CODE**/ > var > $validate=array( 'tax_years_id'=>array('required'=>VALID_NOT_EMPTY, > > 'maxlength'=>array('rule'=>array('between',1,3)), > > 'number'=>VALID_NUMBER)); > /CODE_END/ > > The result is that if the user doesn't select an element from the > select box, there is no error message displayed and the validation is > passed but the form data is not stored in DB, because the field > "tax_years_id" doesn't have default value which is correct behaviour. > > I've tried with 'showEmpty' set to true but with no success. If there > is no value selected in select box, the passed array doesn't even have > an a element called 'tax_years_id'. (i make a dump of $this->data and > in the array element with name 'tax_years_id' is missing). I've also > tried to make an empty element and select it by default, but I think > this is "ugly" approach, because if user selects some tax year but > form validation fails by reason of other wrong filled field and > selected element in tax year select box is lost. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---