Re: Position of label on checkbox inputs
OK, ok :) So, use $form->label(), then... I'm sure you know this quite well. It was a simple example to show a very simple solution... On Nov 5, 5:35 am, grigri <[EMAIL PROTECTED]> wrote: > You can change the apparent (visible) position of the checkbox/label > with good css-fu, so it doesn't really matter either way, imho. > > Like I said above, we could use a repository of css files for laying > out cake forms in various ways. > > > You could use $form->checkbox(); > > or simply: This is my field: input('something', > > array('label'=>false, 'type'=>'checkbox')); ?> > > That's a bad idea. The "label" ('This is my field') won't be a > "proper" label and won't be associated with the checkbox through the > dom. There is of course the "screenreader issue", but apart from that > associating labels with checkboxes/radio buttons is good because > clicking on the label also clicks on the checkbox, giving the user a > larger target area. > > On Oct 31, 3:07 pm, Jacek Ziółkowski <[EMAIL PROTECTED]> wrote: > > > Yeah, that's a correct assumption when using checkboxes in separate > > rows. I got the same issue, because my project uses several checkboxes > > in a single line - it makes confusion, i.e. > > [X] C [X] M [_] Y [_] K > > > looks dumb and nonsensical. > > I was thinking of extending the $form->checkbox helper with an option to > > alter this, but the method posted by teknoid is much much better due to > > its readability and complete lack of coding needed. > > > "My field:" $form->checkbox(...) with label set to false works best. > > > grigri pisze: > > > > It is common practice to have labels for most form elements before > > > (above or to the left of) the element itself, except for radio buttons > > > and checkboxes, where the norm is for the label to be on the right. > > > > [x] Bacon > > > [x] Eggs > > > [x] Sausages > > > > easier to read than > > > > Bacon [x] > > > Eggs [x] > > > Sausages [x] > > > > I've never had a problem styling forms with the standard form helper > > > methods. > > > > (On an unrelated note, are there any collections of CSS files for > > > cakephp forms? Might be a handy resource to create one. The bakery > > > style is ok, but a drop-in solution for columnar forms that work > > > directly with the form helper would be cool. A sort of "CSS Cake > > > Garden" if you will.) > > > > hth > > > grigri > > > > On Oct 31, 9:52 am, Tom Singer <[EMAIL PROTECTED]> wrote: > > > >> Hi, > > > >> Is there a reason $out is appended to the end in form->input when > > >> $type is set to checkbox? This behaviour is different to all the other > > >> types which place label before the input and is causing me issues with > > >> my layout. I can fix this by moving the out variable between $before > > >> and the checkbox but i don't want to do this if $out is at the end by > > >> design and this will break something. I have had no issues so far but > > >> this may break somethign i have not come across yet. > > > >> I am using version 1.2.0.7296 RC2 > > > >> Thanks, > > > >> Tom > > > >> [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php > > >> diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ > > >> form.php > > >> index 33639b2..35d06c6 100644 > > >> --- a/cake/libs/view/helpers/form.php > > >> +++ b/cake/libs/view/helpers/form.php > > >> @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { > > >> unset($divOptions); > > >> break; > > >> case 'checkbox': > > >> - $out = $before . > > >> $this->checkbox($fieldName, $options) . $between . $out; > > > >> + $out = $before . $out . > > >> $this->checkbox($fieldName, $options) . $between; > > > >> break; > > >> case 'radio': > > >> $out = $before . $out . $this- > > > >>> radio($fieldName, $radioOptions, $options) . $between; > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Position of label on checkbox inputs
I respectfully disagree with it being a bad idea. It was an example, so if taken literally then perhaps yes, but it was an example to show that one can create their own label (that would also then be associated with the input itself). Although we'd have to manually define the input the label is associated to in the HTML of the view, even if there was a change to the database field, we'd have to edit the view code to match anyway...so we lose no dynamic abilities if it's what we want...and as you so eloquently put, if we *later* wanted to change how ALL labels are viewed or positioned on a site, we can then use CSS. ;-) If anyone's confused on the proper label HTML code, then can just look at what the helper creates first, and then use that manually in the desired position. (Though I'd hope you'd know about the *for* attribute being associated to the respective element ID already!) On Nov 5, 5:35 am, grigri <[EMAIL PROTECTED]> wrote: > You can change the apparent (visible) position of the checkbox/label > with good css-fu, so it doesn't really matter either way, imho. > > Like I said above, we could use a repository of css files for laying > out cake forms in various ways. > > > You could use $form->checkbox(); > > or simply: This is my field: input('something', > > array('label'=>false, 'type'=>'checkbox')); ?> > > That's a bad idea. The "label" ('This is my field') won't be a > "proper" label and won't be associated with the checkbox through the > dom. There is of course the "screenreader issue", but apart from that > associating labels with checkboxes/radio buttons is good because > clicking on the label also clicks on the checkbox, giving the user a > larger target area. > > On Oct 31, 3:07 pm, Jacek Ziółkowski <[EMAIL PROTECTED]> wrote: > > > > > Yeah, that's a correct assumption when using checkboxes in separate > > rows. I got the same issue, because my project uses several checkboxes > > in a single line - it makes confusion, i.e. > > [X] C [X] M [_] Y [_] K > > > looks dumb and nonsensical. > > I was thinking of extending the $form->checkbox helper with an option to > > alter this, but the method posted by teknoid is much much better due to > > its readability and complete lack of coding needed. > > > "My field:" $form->checkbox(...) with label set to false works best. > > > grigri pisze: > > > > It is common practice to have labels for most form elements before > > > (above or to the left of) the element itself, except for radio buttons > > > and checkboxes, where the norm is for the label to be on the right. > > > > [x] Bacon > > > [x] Eggs > > > [x] Sausages > > > > easier to read than > > > > Bacon [x] > > > Eggs [x] > > > Sausages [x] > > > > I've never had a problem styling forms with the standard form helper > > > methods. > > > > (On an unrelated note, are there any collections of CSS files for > > > cakephp forms? Might be a handy resource to create one. The bakery > > > style is ok, but a drop-in solution for columnar forms that work > > > directly with the form helper would be cool. A sort of "CSS Cake > > > Garden" if you will.) > > > > hth > > > grigri > > > > On Oct 31, 9:52 am, Tom Singer <[EMAIL PROTECTED]> wrote: > > > >> Hi, > > > >> Is there a reason $out is appended to the end in form->input when > > >> $type is set to checkbox? This behaviour is different to all the other > > >> types which place label before the input and is causing me issues with > > >> my layout. I can fix this by moving the out variable between $before > > >> and the checkbox but i don't want to do this if $out is at the end by > > >> design and this will break something. I have had no issues so far but > > >> this may break somethign i have not come across yet. > > > >> I am using version 1.2.0.7296 RC2 > > > >> Thanks, > > > >> Tom > > > >> [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php > > >> diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ > > >> form.php > > >> index 33639b2..35d06c6 100644 > > >> --- a/cake/libs/view/helpers/form.php > > >> +++ b/cake/libs/view/helpers/form.php > > >> @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { > > >> unset($divOptions); > > >> break; > > >> case 'checkbox': > > >> - $out = $before . > > >> $this->checkbox($fieldName, $options) . $between . $out; > > > >> + $out = $before . $out . > > >> $this->checkbox($fieldName, $options) . $between; > > > >> break; > > >> case 'radio': > > >> $out = $before . $out . $this- > > > >>> radio($fieldName, $radioOptions, $options) . $between;- Hide quoted > > >>> text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this
Re: Position of label on checkbox inputs
You can change the apparent (visible) position of the checkbox/label with good css-fu, so it doesn't really matter either way, imho. Like I said above, we could use a repository of css files for laying out cake forms in various ways. > You could use $form->checkbox(); > or simply: This is my field: input('something', > array('label'=>false, 'type'=>'checkbox')); ?> That's a bad idea. The "label" ('This is my field') won't be a "proper" label and won't be associated with the checkbox through the dom. There is of course the "screenreader issue", but apart from that associating labels with checkboxes/radio buttons is good because clicking on the label also clicks on the checkbox, giving the user a larger target area. On Oct 31, 3:07 pm, Jacek Ziółkowski <[EMAIL PROTECTED]> wrote: > Yeah, that's a correct assumption when using checkboxes in separate > rows. I got the same issue, because my project uses several checkboxes > in a single line - it makes confusion, i.e. > [X] C [X] M [_] Y [_] K > > looks dumb and nonsensical. > I was thinking of extending the $form->checkbox helper with an option to > alter this, but the method posted by teknoid is much much better due to > its readability and complete lack of coding needed. > > "My field:" $form->checkbox(...) with label set to false works best. > > grigri pisze: > > > It is common practice to have labels for most form elements before > > (above or to the left of) the element itself, except for radio buttons > > and checkboxes, where the norm is for the label to be on the right. > > > [x] Bacon > > [x] Eggs > > [x] Sausages > > > easier to read than > > > Bacon [x] > > Eggs [x] > > Sausages [x] > > > I've never had a problem styling forms with the standard form helper > > methods. > > > (On an unrelated note, are there any collections of CSS files for > > cakephp forms? Might be a handy resource to create one. The bakery > > style is ok, but a drop-in solution for columnar forms that work > > directly with the form helper would be cool. A sort of "CSS Cake > > Garden" if you will.) > > > hth > > grigri > > > On Oct 31, 9:52 am, Tom Singer <[EMAIL PROTECTED]> wrote: > > >> Hi, > > >> Is there a reason $out is appended to the end in form->input when > >> $type is set to checkbox? This behaviour is different to all the other > >> types which place label before the input and is causing me issues with > >> my layout. I can fix this by moving the out variable between $before > >> and the checkbox but i don't want to do this if $out is at the end by > >> design and this will break something. I have had no issues so far but > >> this may break somethign i have not come across yet. > > >> I am using version 1.2.0.7296 RC2 > > >> Thanks, > > >> Tom > > >> [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php > >> diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ > >> form.php > >> index 33639b2..35d06c6 100644 > >> --- a/cake/libs/view/helpers/form.php > >> +++ b/cake/libs/view/helpers/form.php > >> @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { > >> unset($divOptions); > >> break; > >> case 'checkbox': > >> - $out = $before . > >> $this->checkbox($fieldName, $options) . $between . $out; > > >> + $out = $before . $out . > >> $this->checkbox($fieldName, $options) . $between; > > >> break; > >> case 'radio': > >> $out = $before . $out . $this- > > >>> radio($fieldName, $radioOptions, $options) . $between; --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Position of label on checkbox inputs
Yeah, that's a correct assumption when using checkboxes in separate rows. I got the same issue, because my project uses several checkboxes in a single line - it makes confusion, i.e. [X] C [X] M [_] Y [_] K looks dumb and nonsensical. I was thinking of extending the $form->checkbox helper with an option to alter this, but the method posted by teknoid is much much better due to its readability and complete lack of coding needed. "My field:" $form->checkbox(...) with label set to false works best. grigri pisze: > It is common practice to have labels for most form elements before > (above or to the left of) the element itself, except for radio buttons > and checkboxes, where the norm is for the label to be on the right. > > [x] Bacon > [x] Eggs > [x] Sausages > > easier to read than > > Bacon [x] > Eggs [x] > Sausages [x] > > I've never had a problem styling forms with the standard form helper > methods. > > (On an unrelated note, are there any collections of CSS files for > cakephp forms? Might be a handy resource to create one. The bakery > style is ok, but a drop-in solution for columnar forms that work > directly with the form helper would be cool. A sort of "CSS Cake > Garden" if you will.) > > hth > grigri > > On Oct 31, 9:52 am, Tom Singer <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> Is there a reason $out is appended to the end in form->input when >> $type is set to checkbox? This behaviour is different to all the other >> types which place label before the input and is causing me issues with >> my layout. I can fix this by moving the out variable between $before >> and the checkbox but i don't want to do this if $out is at the end by >> design and this will break something. I have had no issues so far but >> this may break somethign i have not come across yet. >> >> I am using version 1.2.0.7296 RC2 >> >> Thanks, >> >> Tom >> >> [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php >> diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ >> form.php >> index 33639b2..35d06c6 100644 >> --- a/cake/libs/view/helpers/form.php >> +++ b/cake/libs/view/helpers/form.php >> @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { >> unset($divOptions); >> break; >> case 'checkbox': >> - $out = $before . $this->checkbox($fieldName, >> $options) . $between . $out; >> >> + $out = $before . $out . >> $this->checkbox($fieldName, $options) . $between; >> >> break; >> case 'radio': >> $out = $before . $out . $this- >> >> >>> radio($fieldName, $radioOptions, $options) . $between; >>> > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Position of label on checkbox inputs
Why? You could use $form->checkbox(); or simply: This is my field: input('something', array('label'=>false, 'type'=>'checkbox')); ?> On Oct 31, 5:52 am, Tom Singer <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a reason $out is appended to the end in form->input when > $type is set to checkbox? This behaviour is different to all the other > types which place label before the input and is causing me issues with > my layout. I can fix this by moving the out variable between $before > and the checkbox but i don't want to do this if $out is at the end by > design and this will break something. I have had no issues so far but > this may break somethign i have not come across yet. > > I am using version 1.2.0.7296 RC2 > > Thanks, > > Tom > > [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php > diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ > form.php > index 33639b2..35d06c6 100644 > --- a/cake/libs/view/helpers/form.php > +++ b/cake/libs/view/helpers/form.php > @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { > unset($divOptions); > break; > case 'checkbox': > - $out = $before . $this->checkbox($fieldName, > $options) . $between . $out; > > + $out = $before . $out . > $this->checkbox($fieldName, $options) . $between; > > break; > case 'radio': > $out = $before . $out . $this- > > >radio($fieldName, $radioOptions, $options) . $between; > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Position of label on checkbox inputs
It is common practice to have labels for most form elements before (above or to the left of) the element itself, except for radio buttons and checkboxes, where the norm is for the label to be on the right. [x] Bacon [x] Eggs [x] Sausages easier to read than Bacon [x] Eggs [x] Sausages [x] I've never had a problem styling forms with the standard form helper methods. (On an unrelated note, are there any collections of CSS files for cakephp forms? Might be a handy resource to create one. The bakery style is ok, but a drop-in solution for columnar forms that work directly with the form helper would be cool. A sort of "CSS Cake Garden" if you will.) hth grigri On Oct 31, 9:52 am, Tom Singer <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a reason $out is appended to the end in form->input when > $type is set to checkbox? This behaviour is different to all the other > types which place label before the input and is causing me issues with > my layout. I can fix this by moving the out variable between $before > and the checkbox but i don't want to do this if $out is at the end by > design and this will break something. I have had no issues so far but > this may break somethign i have not come across yet. > > I am using version 1.2.0.7296 RC2 > > Thanks, > > Tom > > [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php > diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ > form.php > index 33639b2..35d06c6 100644 > --- a/cake/libs/view/helpers/form.php > +++ b/cake/libs/view/helpers/form.php > @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { > unset($divOptions); > break; > case 'checkbox': > - $out = $before . $this->checkbox($fieldName, > $options) . $between . $out; > > + $out = $before . $out . > $this->checkbox($fieldName, $options) . $between; > > break; > case 'radio': > $out = $before . $out . $this- > > >radio($fieldName, $radioOptions, $options) . $between; --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Position of label on checkbox inputs
Hi, Is there a reason $out is appended to the end in form->input when $type is set to checkbox? This behaviour is different to all the other types which place label before the input and is causing me issues with my layout. I can fix this by moving the out variable between $before and the checkbox but i don't want to do this if $out is at the end by design and this will break something. I have had no issues so far but this may break somethign i have not come across yet. I am using version 1.2.0.7296 RC2 Thanks, Tom [EMAIL PROTECTED]:~/jobzone$ git diff cake/libs/view/helpers/form.php diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/ form.php index 33639b2..35d06c6 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -735,7 +735,7 @@ class FormHelper extends AppHelper { unset($divOptions); break; case 'checkbox': - $out = $before . $this- >checkbox($fieldName, $options) . $between . $out; + $out = $before . $out . $this- >checkbox($fieldName, $options) . $between; break; case 'radio': $out = $before . $out . $this- >radio($fieldName, $radioOptions, $options) . $between; --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---