Re: validate select field in a Model
- Jon On Nov 1, 2012 5:23 AM, Chris chris...@yahoo.com wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: validate select field in a Model
A select dropdown will never be empty unless one of the options is an empty string. - Jon On Nov 1, 2012 5:23 AM, Chris chris...@yahoo.com wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: validate select field in a Model
The logic you are trying to use it produce html as- select option value=0unknown/option option value=1male/option option value=2female/option /select So you should use in following way- Configure::write('User.genders', array(''='unknown', '1'='male', '2'='female')); rest code is same On Thu, Nov 1, 2012 at 3:53 PM, Chris chris...@yahoo.com wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Chetan Varshney Ektanjali Softwares Pvt Ltd -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: validate select field in a Model
hi jsundquist,... in fact I'm getting an 2 empty spots on top with no options empty,... what if the new user who's trying to signup accidentally deselect it ? ,... and there we need the red wrapping warning with message,... 'message' = 'Gender must be valid',... anyway,... for now I'm validating from a controller but will be nice to do it from Model,... elseif(empty($this-data['User']['gender'])) { $this-flash('error', ucfirst(i18n::translate('you must enter valid Gender'))); $this-redirect($_SERVER['HTTP_REFERER']); } thanks man,... On Thursday, November 1, 2012 5:13:48 AM UTC-7, jsundquist wrote: A select dropdown will never be empty unless one of the options is an empty string. - Jon On Nov 1, 2012 5:23 AM, Chris chri...@yahoo.com javascript: wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake...@googlegroups.comjavascript: . To unsubscribe from this group, send email to cake-php+u...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: validate select field in a Model
thanks chetan,... I have tried that too,... no luck,... steel having empty spots on top of options,... please take a look of it,... http://www.hamayk.com/signup I have remove 'unknown' On Thursday, November 1, 2012 5:47:04 AM UTC-7, chetan varshney wrote: The logic you are trying to use it produce html as- select option value=0unknown/option option value=1male/option option value=2female/option /select So you should use in following way- Configure::write('User.genders', array(''='unknown', '1'='male', '2'='female')); rest code is same On Thu, Nov 1, 2012 at 3:53 PM, Chris chri...@yahoo.com javascript:wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake...@googlegroups.comjavascript: . To unsubscribe from this group, send email to cake-php+u...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Chetan Varshney Ektanjali Softwares Pvt Ltd -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: validate select field in a Model
use like this echo $this-Form-input(gender , array('type' = 'select', 'options'=$genders))? good luck all set On Thu, Nov 1, 2012 at 10:16 PM, Chris chris...@yahoo.com wrote: thanks chetan,... I have tried that too,... no luck,... steel having empty spots on top of options,... please take a look of it,... http://www.hamayk.com/signup I have remove 'unknown' On Thursday, November 1, 2012 5:47:04 AM UTC-7, chetan varshney wrote: The logic you are trying to use it produce html as- select option value=0unknown/option option value=1male/option option value=2female/option /select So you should use in following way- Configure::write('User.**genders', array(''='unknown', '1'='male', '2'='female')); rest code is same On Thu, Nov 1, 2012 at 3:53 PM, Chris chri...@yahoo.com wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.**genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.**genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/**CakePHPhttps://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake...@googlegroups.com. To unsubscribe from this group, send email to cake-php+u...@** googlegroups.com. Visit this group at http://groups.google.com/**group/cake-php?hl=enhttp://groups.google.com/group/cake-php?hl=en . -- Chetan Varshney Ektanjali Softwares Pvt Ltd -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Chetan Varshney Director Ektanjali Softwares Pvt Ltd Delhi India Mobile: 91 9891538749 | Email: chetanvarsh...@gmail.com | Skype: chetan-varshney EktaSoftwares.Com -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: validate select field in a Model
thanks chetan,... ! it works ...! no empty spots,... On Thursday, November 1, 2012 10:04:38 AM UTC-7, chetan varshney wrote: use like this echo $this-Form-input(gender , array('type' = 'select', 'options'=$genders))? good luck all set On Thu, Nov 1, 2012 at 10:16 PM, Chris chri...@yahoo.com javascript:wrote: thanks chetan,... I have tried that too,... no luck,... steel having empty spots on top of options,... please take a look of it,... http://www.hamayk.com/signup I have remove 'unknown' On Thursday, November 1, 2012 5:47:04 AM UTC-7, chetan varshney wrote: The logic you are trying to use it produce html as- select option value=0unknown/option option value=1male/option option value=2female/option /select So you should use in following way- Configure::write('User.**genders', array(''='unknown', '1'='male', '2'='female')); rest code is same On Thu, Nov 1, 2012 at 3:53 PM, Chris chri...@yahoo.com wrote: hi guys,... I'm using cake 1.3 how can I validate select field from Model,? what I have in bootstrap: Configure::write('User.**genders', array('unknown', 'male', 'female')); in a view: tr tdstrong?php echo ucfirst(__('gender', true)) ?/strong ?php $genders = array(Configure::read('User.**genders')); echo $this-Form-select('gender', $genders) ? /td /tr and in a Model: var $validate = array( 'gender' = array( 'rule' = 'notEmpty', 'required' = true, 'message' = 'Gender must be valid', ), ); I'm not getting warning of red box with Gender must be valid how can I do this? thanks in advance chris -- Like Us on FaceBook https://www.facebook.com/**CakePHPhttps://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake...@googlegroups.com. To unsubscribe from this group, send email to cake-php+u...@** googlegroups.com. Visit this group at http://groups.google.com/**group/cake-php?hl=enhttp://groups.google.com/group/cake-php?hl=en . -- Chetan Varshney Ektanjali Softwares Pvt Ltd -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake...@googlegroups.comjavascript: . To unsubscribe from this group, send email to cake-php+u...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- Chetan Varshney Director Ektanjali Softwares Pvt Ltd Delhi India Mobile: 91 9891538749 | Email: chetanv...@gmail.com javascript: | Skype: chetan-varshney EktaSoftwares.Com -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.