Re: having empty entry in selecttag selected
Hi Spamfunk,The following gives me a select box with the vlank item selected by default. $html->selectTag('Customer/county_id', $countyArray, $html->tagValue( 'Customer/county_id'), array('id' => 'customer_county_id'));HTH,Sonic --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Hi Sonic! I understood everything Nate posted. I use the automated insertion of the blank list item. My problem was, that this blank list item is not selected by default. Cheers Felix --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
You didn't have to extend the helper at all.Nate was saying that by default the select tag in the html helper will add a blank list item.I think you thought that he was trying to say that you needed an empty element in the data array which is not the case. Sonic --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Hi Davide, On Oct 24, 11:29 am, davide <[EMAIL PROTECTED]> wrote: > Why didn't you extend the HtmlHelper class directly and then reimplement > only the required method? So in all of your application, you have only > to include your helper and will have all the htmlHelper functionality That's a good point! I think I will change it the way you recommended it. Cheers Felix --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
[EMAIL PROTECTED] wrote: > ... > Basically I copied the function selectTag and named it to myselectTag. > The only thing I had to do is to change the following line and mark it > as selected: > > if ($showEmpty == true) { >$select[] = sprintf($this->tags['selectempty'],'selected'); > } I've not followed the thread so I could say something wrong or useless. Why didn't you extend the HtmlHelper class directly and then reimplement only the required method? So in all of your application, you have only to include your helper and will have all the htmlHelper functionality plus yours. Bye Davide -- By the power of Greyskull... signature.asc Description: OpenPGP digital signature
Re: having empty entry in selecttag selected
Now it work's fine. That's what I did: I've created a helper in the app/views/helpers directory with the name myhtml.php. That file contains a class MyhtmlHelper which extends Helper. Basically I copied the function selectTag and named it to myselectTag. The only thing I had to do is to change the following line and mark it as selected: if ($showEmpty == true) { $select[] = sprintf($this->tags['selectempty'],'selected'); } Cheers Felix --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Ok, thanks. That helps. The solution isn't as simple as I expected, but it seems that I have to work on an own method. Cheers Felix --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Hi, > Does no one know how to declare a selectTag, so that the first empty > entry is selected by default? Normally, you would set an entry to be selected by default like this: $html->selectTag( 'User/contact', $Contactlist, $html->tagValue('User/contact') ? $html->tagValue('User/contact') : 'xxx', array( 'size' => '10', 'multiple' => 'multiple') ) where xxx is the option value to be selected. The automatically added element by $html->selectTag() has no value, so I see only 2 possibilities: - you add the empty element "by hand" to $Contactlist and give it a value - or you write your own helper method selectTag() where you can assign a value to the autogenerated element. Hope this helps :) Heiner > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Does no one know how to declare a selectTag, so that the first empty entry is selected by default? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
No, the first element in the actual array has a value. I would like to have the empty element added by the selectTag to be selected by default. But somehow none of the items is selected, when i load the page. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Are you saying the first element in the actual array is empty, because you don't need to do that, as selectTag will add an empty element at the beginning by default, unless you tell it not to. Otherwise, $selected should be set to the key value of the array element that should be selected. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
Hi Nate, you mean something like this? echo $html->selectTag('User/contact', $Contactlist, null, array( 'size' => '10', 'multiple' => 'multiple')); unfortunately this is not working aswell. Nothing is selected by default. There must be a simple solutionbut I don't get it. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: having empty entry in selecttag selected
It should work if you just pass null to $selected (which is the default value). http://api.cakephp.org/class_html_helper.html#0a0a7c56c21b7d7352fd99158350dfc5 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
having empty entry in selecttag selected
Hi there, I have a selecttag filled with an array. The first entry in the selecttag-list is empty. Now I want that empty entry to be selected by default. Here is my code in the view: echo $html->selectTag('User/contact', $Contactlist, '0', array( 'size' => '10', 'multiple' => 'multiple')) But the 0 doesn't select the first empty entry. Thanks Felix --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---