Re: checkboxes with alternative value
Hi Fabio - same way you would do for any array - look at the output from this: foreach (data['Amenity'] as $key => $value){ echo "key: ".$key.""; echo "name: ".$value[name].""; } On Aug 31, 8:01 pm, fabio <3bi...@gmail.com> wrote: > Dears delocalizer and DrLoboto, > > tnx for your suggestions... i'm working in that way now but i hade > some difficulties... > > Basically I have this portion of the $form array: > > [Amenity] => Array > ( > [0] => Array > ( > [id] => 6 > [name] => Pets > [AmenitiesProperty] => Array > ( > [id] => 17 > [property_id] => 1 > [amenity_id] => 6 > [specify] => no > ) > > ) > > [1] => Array > ( > [id] => 1 > [name] => Type > [AmenitiesProperty] => Array > ( > [id] => 16 > [property_id] => 1 > [amenity_id] => 1 > [specify] => no > ) > > ) > > [2] => Array > ( > [id] => 2 > [name] => Floors > [AmenitiesProperty] => Array > ( > [id] => 15 > [property_id] => 1 > [amenity_id] => 2 > [specify] => no > ) > > ) > > [3] => Array > ( > [id] => 3 > [name] => Last Remodeled > [AmenitiesProperty] => Array > ( > [id] => 14 > [property_id] => 1 > [amenity_id] => 3 > [specify] => no > ) > > ) > > [4] => Array > ( > [id] => 4 > [name] => Constructed > [AmenitiesProperty] => Array > ( > [id] => 13 > [property_id] => 1 > [amenity_id] => 4 > [specify] => no > ) > > ) > > [5] => Array > ( > [id] => 5 > [name] => Smoking > [AmenitiesProperty] => Array > ( > [id] => 12 > [property_id] => 1 > [amenity_id] => 5 > [specify] => no > ) > > ) > > ) > > and i need looping through it and echoing separte elements > individually... > > I know how i can access and echo elements from this array: > > ie. > echo $this->data['Amenity'][0]['name']; > > and i think i should use a "for each ... " statement... but how can i > loop this kind of multidimensional associative array in CakePHP ? > > tnx a lot > > fabio > > On 30 Ago, 06:50, delocalizer wrote: > > > Hi Fabio; > > Dr Loboto is correct - you'll have to output the elements individually > > rather than as a group. You can use the form helper to create the > > individual checkboxes, but getting the text field to display inline > > nicely may require some tinkering. Or just code the html yourself - > > that's what I ended up doing recently for a similar scenario with > > radio buttons. Form helper is nice but can't be expected to cover > > every formatting possibility. > > Don't forget to add some javascript that will clear the text field > > again if its checkbox is unselected > > regards, > > C. > > > On 28 Ago, 19:01, fabio <3bi...@gmail.com> wrote: > > > > Thanks again Dr.Loboto, > > > > that's what i came up to as well, but it works only for the last > > > checkbox of the list (or the first if i used 'before' parameter)... > > > what i need is a text field associated for each checkbox of a grou
Re: checkboxes with alternative value
Dears delocalizer and DrLoboto, tnx for your suggestions... i'm working in that way now but i hade some difficulties... Basically I have this portion of the $form array: [Amenity] => Array ( [0] => Array ( [id] => 6 [name] => Pets [AmenitiesProperty] => Array ( [id] => 17 [property_id] => 1 [amenity_id] => 6 [specify] => no ) ) [1] => Array ( [id] => 1 [name] => Type [AmenitiesProperty] => Array ( [id] => 16 [property_id] => 1 [amenity_id] => 1 [specify] => no ) ) [2] => Array ( [id] => 2 [name] => Floors [AmenitiesProperty] => Array ( [id] => 15 [property_id] => 1 [amenity_id] => 2 [specify] => no ) ) [3] => Array ( [id] => 3 [name] => Last Remodeled [AmenitiesProperty] => Array ( [id] => 14 [property_id] => 1 [amenity_id] => 3 [specify] => no ) ) [4] => Array ( [id] => 4 [name] => Constructed [AmenitiesProperty] => Array ( [id] => 13 [property_id] => 1 [amenity_id] => 4 [specify] => no ) ) [5] => Array ( [id] => 5 [name] => Smoking [AmenitiesProperty] => Array ( [id] => 12 [property_id] => 1 [amenity_id] => 5 [specify] => no ) ) ) and i need looping through it and echoing separte elements individually... I know how i can access and echo elements from this array: ie. echo $this->data['Amenity'][0]['name']; and i think i should use a "for each ... " statement... but how can i loop this kind of multidimensional associative array in CakePHP ? tnx a lot fabio On 30 Ago, 06:50, delocalizer wrote: > Hi Fabio; > Dr Loboto is correct - you'll have to output the elements individually > rather than as a group. You can use the form helper to create the > individual checkboxes, but getting the text field to display inline > nicely may require some tinkering. Or just code the html yourself - > that's what I ended up doing recently for a similar scenario with > radio buttons. Form helper is nice but can't be expected to cover > every formatting possibility. > Don't forget to add some javascript that will clear the text field > again if its checkbox is unselected > regards, > C. > > On 28 Ago, 19:01, fabio <3bi...@gmail.com> wrote: > > > > > Thanks again Dr.Loboto, > > > that's what i came up to as well, but it works only for the last > > checkbox of the list (or the first if i used 'before' parameter)... > > what i need is a text field associated for each checkbox of a group of > > checkboxes... don't know if it's possible at this point... :-( > > > damn ! i think i'll end avoiding the FormHelper and coding it with > > pure html even if like this i'm gonna loose all the benefits of Cake > > > Anyway thank you again for your tips > > > fabio > > > On 28 Ago, 10:16, "Dr. Loboto" wrote: > > > > Read > > > manual.http://book.cakephp.org/view/191/options-before-options-between-optio... > > > > echo $form->input( > > > 'Amenity',
Re: checkboxes with alternative value
Hi Fabio; Dr Loboto is correct - you'll have to output the elements individually rather than as a group. You can use the form helper to create the individual checkboxes, but getting the text field to display inline nicely may require some tinkering. Or just code the html yourself - that's what I ended up doing recently for a similar scenario with radio buttons. Form helper is nice but can't be expected to cover every formatting possibility. Don't forget to add some javascript that will clear the text field again if its checkbox is unselected regards, C. On 28 Ago, 19:01, fabio <3bi...@gmail.com> wrote: > Thanks again Dr.Loboto, > > that's what i came up to as well, but it works only for the last > checkbox of the list (or the first if i used 'before' parameter)... > what i need is a text field associated for each checkbox of a group of > checkboxes... don't know if it's possible at this point... :-( > > damn ! i think i'll end avoiding the FormHelper and coding it with > pure html even if like this i'm gonna loose all the benefits of Cake > > Anyway thank you again for your tips > > fabio > > On 28 Ago, 10:16, "Dr. Loboto" wrote: > > > Read > > manual.http://book.cakephp.org/view/191/options-before-options-between-optio... > > > echo $form->input( > > 'Amenity', > > array( > > 'type' => 'select', > > 'multiple' => 'checkbox', > > 'after' => $form->input( > > 'User.name', > > array('onfocus' => 'CheckCheckBox(this.form)') > > ) > > ) > > ); > > > On Aug 28, 2:57 pm, fabio <3bi...@gmail.com> wrote: > > > > Dear Dr.Loboto, thank you very much for your suggestion... i'm > > > handling on it but i would first need to know how to set the > > > FormHelper options to show one text field beside each checkbox... > > > > I was thinking about something like markup injections using > > > parameters "between[string]" or "after[string]" but i'm not really > > > sure it make sense... > > > > Any additional suggestion ? > > > > thanks a lot, really appreciate > > > > fabio > > > > On 28 Ago, 07:59, "Dr. Loboto" wrote: > > > > > echo $form->input('User.name', array('onfocus' => 'CheckCheckBox > > > > (this.form)')); > > > > > On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote: > > > > > > Dear all, > > > > > > i'm a CakePHP newbie and i'm looking for some help regarding a > > > > > particular use of checkboxes in a form. > > > > > > Basically i've got a check-boxes-section in the form of a baked > > > > > edit.ctp, called with a basic > > > > > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' => > > > > > 'checkbox' )); > > > > > > The models refers to a join table with an additional field 'specify': > > > > > > CREATE TABLE IF NOT EXISTS `amenities_properties` ( > > > > > `id` int(11) unsigned NOT NULL auto_increment, > > > > > `property_id` int(11) NOT NULL, > > > > > `amenity_id` int(11) NOT NULL, > > > > > `specify` varchar(100) NOT NULL default 'yes', > > > > > PRIMARY KEY (`id`) > > > > > ); > > > > > > The idea is to set values like this: > > > > > > 'no' if unchecked > > > > > 'yes' ..if checked > > > > > 'whatever'... if checked and a string 'whatever' is inserted > > > > > > In other words I need to associate to each checkboxes an additional > > > > > input text field to be eventually filled only if the checkboxes are > > > > > previously checked > > > > > > I've found what it seems a perfect solution for this, but now I need > > > > > some help to implement it in CakePHP terms. > > > > > > Here it is: > > > > > > http://www.w3.org/ > > > > > TR/html4/strict.dtd"> > > > > > > > > > > > > > > > > > > > > Test Checkbox > > > > > > > > > > function CheckCheckBox(frm) > > > > > { > > > > > if (!frm.CheckThis.checked) > > > > > frm.CheckThis.focus() > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To insert your name check the box. > > > > > > > > > > Name: > > > > > > > > > onfocus="CheckCheckBox > > > > > (this.form)"> > > > > > > > > > > > > > > > > > > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html > > > > > ) > > > > > > How you can see, the javascript function allows the user to input an > > > > > alternative value to yes/no only if the checkbox is previously checked > > > > > > So the point is: > > > > > how to get done this behaviour togheter with CakePHP default Form > > > > > Helper ? > > > > > Do you think it's possible somehow or another approach would be better > > > > > to achieve the same result ? > > > > > > Thanks a lot in advance for some suggestions > > > > > > Best regards > > > > > >
Re: checkboxes with alternative value
If you need textfield for every checkbox, do not output them as group but do it individually. On Aug 28, 4:01 pm, fabio <3bi...@gmail.com> wrote: > Thanks again Dr.Loboto, > > that's what i came up to as well, but it works only for the last > checkbox of the list (or the first if i used 'before' parameter)... > what i need is a text field associated for each checkbox of a group of > checkboxes... don't know if it's possible at this point... :-( > > damn ! i think i'll end avoiding the FormHelper and coding it with > pure html even if like this i'm gonna loose all the benefits of Cake > > Anyway thank you again for your tips > > fabio > > On 28 Ago, 10:16, "Dr. Loboto" wrote: > > > > > Read > > manual.http://book.cakephp.org/view/191/options-before-options-between-optio... > > > echo $form->input( > > 'Amenity', > > array( > > 'type' => 'select', > > 'multiple' => 'checkbox', > > 'after' => $form->input( > > 'User.name', > > array('onfocus' => 'CheckCheckBox(this.form)') > > ) > > ) > > ); > > > On Aug 28, 2:57 pm, fabio <3bi...@gmail.com> wrote: > > > > Dear Dr.Loboto, thank you very much for your suggestion... i'm > > > handling on it but i would first need to know how to set the > > > FormHelper options to show one text field beside each checkbox... > > > > I was thinking about something like markup injections using > > > parameters "between[string]" or "after[string]" but i'm not really > > > sure it make sense... > > > > Any additional suggestion ? > > > > thanks a lot, really appreciate > > > > fabio > > > > On 28 Ago, 07:59, "Dr. Loboto" wrote: > > > > > echo $form->input('User.name', array('onfocus' => 'CheckCheckBox > > > > (this.form)')); > > > > > On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote: > > > > > > Dear all, > > > > > > i'm a CakePHP newbie and i'm looking for some help regarding a > > > > > particular use of checkboxes in a form. > > > > > > Basically i've got a check-boxes-section in the form of a baked > > > > > edit.ctp, called with a basic > > > > > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' => > > > > > 'checkbox' )); > > > > > > The models refers to a join table with an additional field 'specify': > > > > > > CREATE TABLE IF NOT EXISTS `amenities_properties` ( > > > > > `id` int(11) unsigned NOT NULL auto_increment, > > > > > `property_id` int(11) NOT NULL, > > > > > `amenity_id` int(11) NOT NULL, > > > > > `specify` varchar(100) NOT NULL default 'yes', > > > > > PRIMARY KEY (`id`) > > > > > ); > > > > > > The idea is to set values like this: > > > > > > 'no' if unchecked > > > > > 'yes' ..if checked > > > > > 'whatever'... if checked and a string 'whatever' is inserted > > > > > > In other words I need to associate to each checkboxes an additional > > > > > input text field to be eventually filled only if the checkboxes are > > > > > previously checked > > > > > > I've found what it seems a perfect solution for this, but now I need > > > > > some help to implement it in CakePHP terms. > > > > > > Here it is: > > > > > > http://www.w3.org/ > > > > > TR/html4/strict.dtd"> > > > > > > > > > > > > > > > > > > > > Test Checkbox > > > > > > > > > > function CheckCheckBox(frm) > > > > > { > > > > > if (!frm.CheckThis.checked) > > > > > frm.CheckThis.focus() > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To insert your name check the box. > > > > > > > > > > Name: > > > > > > > > > onfocus="CheckCheckBox > > > > > (this.form)"> > > > > > > > > > > > > > > > > > > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html > > > > > ) > > > > > > How you can see, the javascript function allows the user to input an > > > > > alternative value to yes/no only if the checkbox is previously checked > > > > > > So the point is: > > > > > how to get done this behaviour togheter with CakePHP default Form > > > > > Helper ? > > > > > Do you think it's possible somehow or another approach would be better > > > > > to achieve the same result ? > > > > > > Thanks a lot in advance for some suggestions > > > > > > Best regards > > > > > > fabio --~--~-~--~~~---~--~~ 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: checkboxes with alternative value
Thanks again Dr.Loboto, that's what i came up to as well, but it works only for the last checkbox of the list (or the first if i used 'before' parameter)... what i need is a text field associated for each checkbox of a group of checkboxes... don't know if it's possible at this point... :-( damn ! i think i'll end avoiding the FormHelper and coding it with pure html even if like this i'm gonna loose all the benefits of Cake Anyway thank you again for your tips fabio On 28 Ago, 10:16, "Dr. Loboto" wrote: > Read > manual.http://book.cakephp.org/view/191/options-before-options-between-optio... > > echo $form->input( > 'Amenity', > array( > 'type' => 'select', > 'multiple' => 'checkbox', > 'after' => $form->input( > 'User.name', > array('onfocus' => 'CheckCheckBox(this.form)') > ) > ) > ); > > On Aug 28, 2:57 pm, fabio <3bi...@gmail.com> wrote: > > > > > Dear Dr.Loboto, thank you very much for your suggestion... i'm > > handling on it but i would first need to know how to set the > > FormHelper options to show one text field beside each checkbox... > > > I was thinking about something like markup injections using > > parameters "between[string]" or "after[string]" but i'm not really > > sure it make sense... > > > Any additional suggestion ? > > > thanks a lot, really appreciate > > > fabio > > > On 28 Ago, 07:59, "Dr. Loboto" wrote: > > > > echo $form->input('User.name', array('onfocus' => 'CheckCheckBox > > > (this.form)')); > > > > On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote: > > > > > Dear all, > > > > > i'm a CakePHP newbie and i'm looking for some help regarding a > > > > particular use of checkboxes in a form. > > > > > Basically i've got a check-boxes-section in the form of a baked > > > > edit.ctp, called with a basic > > > > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' => > > > > 'checkbox' )); > > > > > The models refers to a join table with an additional field 'specify': > > > > > CREATE TABLE IF NOT EXISTS `amenities_properties` ( > > > > `id` int(11) unsigned NOT NULL auto_increment, > > > > `property_id` int(11) NOT NULL, > > > > `amenity_id` int(11) NOT NULL, > > > > `specify` varchar(100) NOT NULL default 'yes', > > > > PRIMARY KEY (`id`) > > > > ); > > > > > The idea is to set values like this: > > > > > 'no' if unchecked > > > > 'yes' ..if checked > > > > 'whatever'... if checked and a string 'whatever' is inserted > > > > > In other words I need to associate to each checkboxes an additional > > > > input text field to be eventually filled only if the checkboxes are > > > > previously checked > > > > > I've found what it seems a perfect solution for this, but now I need > > > > some help to implement it in CakePHP terms. > > > > > Here it is: > > > > > http://www.w3.org/ > > > > TR/html4/strict.dtd"> > > > > > > > > > > > > > > > > Test Checkbox > > > > > > > > function CheckCheckBox(frm) > > > > { > > > > if (!frm.CheckThis.checked) > > > > frm.CheckThis.focus() > > > > } > > > > > > > > > > > > > > > > > > > > > > > > To insert your name check the box. > > > > > > > > Name: > > > > > > > onfocus="CheckCheckBox > > > > (this.form)"> > > > > > > > > > > > > > > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html > > > > ) > > > > > How you can see, the javascript function allows the user to input an > > > > alternative value to yes/no only if the checkbox is previously checked > > > > > So the point is: > > > > how to get done this behaviour togheter with CakePHP default Form > > > > Helper ? > > > > Do you think it's possible somehow or another approach would be better > > > > to achieve the same result ? > > > > > Thanks a lot in advance for some suggestions > > > > > Best regards > > > > > fabio --~--~-~--~~~---~--~~ 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: checkboxes with alternative value
Read manual. http://book.cakephp.org/view/191/options-before-options-between-options-separator-a echo $form->input( 'Amenity', array( 'type' => 'select', 'multiple' => 'checkbox', 'after' => $form->input( 'User.name', array('onfocus' => 'CheckCheckBox(this.form)') ) ) ); On Aug 28, 2:57 pm, fabio <3bi...@gmail.com> wrote: > Dear Dr.Loboto, thank you very much for your suggestion... i'm > handling on it but i would first need to know how to set the > FormHelper options to show one text field beside each checkbox... > > I was thinking about something like markup injections using > parameters "between[string]" or "after[string]" but i'm not really > sure it make sense... > > Any additional suggestion ? > > thanks a lot, really appreciate > > fabio > > On 28 Ago, 07:59, "Dr. Loboto" wrote: > > > > > echo $form->input('User.name', array('onfocus' => 'CheckCheckBox > > (this.form)')); > > > On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote: > > > > Dear all, > > > > i'm a CakePHP newbie and i'm looking for some help regarding a > > > particular use of checkboxes in a form. > > > > Basically i've got a check-boxes-section in the form of a baked > > > edit.ctp, called with a basic > > > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' => > > > 'checkbox' )); > > > > The models refers to a join table with an additional field 'specify': > > > > CREATE TABLE IF NOT EXISTS `amenities_properties` ( > > > `id` int(11) unsigned NOT NULL auto_increment, > > > `property_id` int(11) NOT NULL, > > > `amenity_id` int(11) NOT NULL, > > > `specify` varchar(100) NOT NULL default 'yes', > > > PRIMARY KEY (`id`) > > > ); > > > > The idea is to set values like this: > > > > 'no' if unchecked > > > 'yes' ..if checked > > > 'whatever'... if checked and a string 'whatever' is inserted > > > > In other words I need to associate to each checkboxes an additional > > > input text field to be eventually filled only if the checkboxes are > > > previously checked > > > > I've found what it seems a perfect solution for this, but now I need > > > some help to implement it in CakePHP terms. > > > > Here it is: > > > > http://www.w3.org/ > > > TR/html4/strict.dtd"> > > > > > > > > > > > > Test Checkbox > > > > > > function CheckCheckBox(frm) > > > { > > > if (!frm.CheckThis.checked) > > > frm.CheckThis.focus() > > > } > > > > > > > > > > > > > > > > > > To insert your name check the box. > > > > > > Name: > > > > > > > > > > > > > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html > > > ) > > > > How you can see, the javascript function allows the user to input an > > > alternative value to yes/no only if the checkbox is previously checked > > > > So the point is: > > > how to get done this behaviour togheter with CakePHP default Form > > > Helper ? > > > Do you think it's possible somehow or another approach would be better > > > to achieve the same result ? > > > > Thanks a lot in advance for some suggestions > > > > Best regards > > > > fabio --~--~-~--~~~---~--~~ 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: checkboxes with alternative value
Dear Dr.Loboto, thank you very much for your suggestion... i'm handling on it but i would first need to know how to set the FormHelper options to show one text field beside each checkbox... I was thinking about something like markup injections using parameters "between[string]" or "after[string]" but i'm not really sure it make sense... Any additional suggestion ? thanks a lot, really appreciate fabio On 28 Ago, 07:59, "Dr. Loboto" wrote: > echo $form->input('User.name', array('onfocus' => 'CheckCheckBox > (this.form)')); > > On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote: > > > > > Dear all, > > > i'm a CakePHP newbie and i'm looking for some help regarding a > > particular use of checkboxes in a form. > > > Basically i've got a check-boxes-section in the form of a baked > > edit.ctp, called with a basic > > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' => > > 'checkbox' )); > > > The models refers to a join table with an additional field 'specify': > > > CREATE TABLE IF NOT EXISTS `amenities_properties` ( > > `id` int(11) unsigned NOT NULL auto_increment, > > `property_id` int(11) NOT NULL, > > `amenity_id` int(11) NOT NULL, > > `specify` varchar(100) NOT NULL default 'yes', > > PRIMARY KEY (`id`) > > ); > > > The idea is to set values like this: > > > 'no' if unchecked > > 'yes' ..if checked > > 'whatever'... if checked and a string 'whatever' is inserted > > > In other words I need to associate to each checkboxes an additional > > input text field to be eventually filled only if the checkboxes are > > previously checked > > > I've found what it seems a perfect solution for this, but now I need > > some help to implement it in CakePHP terms. > > > Here it is: > > > http://www.w3.org/ > > TR/html4/strict.dtd"> > > > > > > > > Test Checkbox > > > > function CheckCheckBox(frm) > > { > > if (!frm.CheckThis.checked) > > frm.CheckThis.focus() > > } > > > > > > > > > > > > To insert your name check the box. > > > > Name: > > > > > > > > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html > > ) > > > How you can see, the javascript function allows the user to input an > > alternative value to yes/no only if the checkbox is previously checked > > > So the point is: > > how to get done this behaviour togheter with CakePHP default Form > > Helper ? > > Do you think it's possible somehow or another approach would be better > > to achieve the same result ? > > > Thanks a lot in advance for some suggestions > > > Best regards > > > fabio --~--~-~--~~~---~--~~ 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: checkboxes with alternative value
echo $form->input('User.name', array('onfocus' => 'CheckCheckBox (this.form)')); On Aug 27, 9:18 pm, fabio <3bi...@gmail.com> wrote: > Dear all, > > i'm a CakePHP newbie and i'm looking for some help regarding a > particular use of checkboxes in a form. > > Basically i've got a check-boxes-section in the form of a baked > edit.ctp, called with a basic > > echo $form->input('Amenity', array( 'type' => 'select', 'multiple' => > 'checkbox' )); > > The models refers to a join table with an additional field 'specify': > > CREATE TABLE IF NOT EXISTS `amenities_properties` ( > `id` int(11) unsigned NOT NULL auto_increment, > `property_id` int(11) NOT NULL, > `amenity_id` int(11) NOT NULL, > `specify` varchar(100) NOT NULL default 'yes', > PRIMARY KEY (`id`) > ); > > The idea is to set values like this: > > 'no' if unchecked > 'yes' ..if checked > 'whatever'... if checked and a string 'whatever' is inserted > > In other words I need to associate to each checkboxes an additional > input text field to be eventually filled only if the checkboxes are > previously checked > > I've found what it seems a perfect solution for this, but now I need > some help to implement it in CakePHP terms. > > Here it is: > > http://www.w3.org/ > TR/html4/strict.dtd"> > > > > Test Checkbox > > function CheckCheckBox(frm) > { > if (!frm.CheckThis.checked) > frm.CheckThis.focus() > } > > > > > > To insert your name check the box. > > Name: > > > > > > (see it in action here:http://www.html.it/articoli/1756/esempio.html > ) > > How you can see, the javascript function allows the user to input an > alternative value to yes/no only if the checkbox is previously checked > > So the point is: > how to get done this behaviour togheter with CakePHP default Form > Helper ? > Do you think it's possible somehow or another approach would be better > to achieve the same result ? > > Thanks a lot in advance for some suggestions > > Best regards > > fabio --~--~-~--~~~---~--~~ 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---