That's an "improvement" request, which has already been completed. Maybe a new bug should be opened just for this case (button elements).
-- Hector On Wed, Dec 23, 2009 at 8:42 AM, Саша Стаменковић <[email protected]>wrote: > This works for me, and for buttons type="submit", not tested in safari, so, > I'm not sure my solution is generic. > > There is a issue http://framework.zend.com/issues/browse/ZF-2465, and > there is my comment at the bottom 29/Nov/09 01:00 AM, but still no > response :( > > Regards, > Saša Stamenković > > > > On Wed, Dec 23, 2009 at 5:29 PM, Hector Virgen <[email protected]> wrote: > >> Looks good! Have you filed a bug report for this? >> >> -- >> Hector >> >> >> >> On Wed, Dec 23, 2009 at 4:28 AM, Саша Стаменковић <[email protected]>wrote: >> >>> O.K. This is better: >>> >>> public function isChecked() >>> { >>> $value = $this->getValue(); >>> if (null === $value) { >>> return false; >>> } >>> >>> return true; >>> } >>> >>> Regards, >>> Saša Stamenković >>> >>> >>> >>> On Wed, Dec 23, 2009 at 12:04 AM, Саша Стаменковић >>> <[email protected]>wrote: >>> >>>> I need to find out exactly which button is clicked, because I have >>>> wizard with multi page form and on each step I have back and forward >>>> button. >>>> >>>> Regards, >>>> Saša Stamenković >>>> >>>> >>>> >>>> On Wed, Dec 23, 2009 at 12:02 AM, Саша Стаменковић >>>> <[email protected]>wrote: >>>> >>>>> You are right, even with: >>>>> >>>>> public function isChecked() >>>>> { >>>>> $value = $this->getValue(); >>>>> if (empty($value)) { >>>>> return true; >>>>> } >>>>> >>>>> return false; >>>>> } >>>>> >>>>> it behaves wrong on WinXP/FF. Must find the way around this... >>>>> >>>>> Regards, >>>>> Saša Stamenković >>>>> >>>>> >>>>> >>>>> On Tue, Dec 22, 2009 at 6:11 PM, Hector Virgen <[email protected]>wrote: >>>>> >>>>>> I get a fatal error when I try that: >>>>>> >>>>>> Fatal error: Can't use method return value in write context in >>>>>>> /Users/hvirgen/Web/projects/virgentech/application/controllers/IndexController.php >>>>>>> on line 49 >>>>>> >>>>>> >>>>>> I swapped it for this test, which is similar to yours: >>>>>> >>>>>> if (!$this->getValue()) { >>>>>> return true; >>>>>> } >>>>>> >>>>>> return false; >>>>>> >>>>>> But it always returns true, even if I clicked a different submit >>>>>> button. Again, this was testing on Chrome for Mac. Other browsers may >>>>>> behave >>>>>> differently. >>>>>> >>>>>> Do you just need to test if the form was submitted, or if a specific >>>>>> button was clicked? >>>>>> >>>>>> -- >>>>>> Hector >>>>>> >>>>>> >>>>>> >>>>>> On Tue, Dec 22, 2009 at 9:04 AM, Саша Стаменковић <[email protected] >>>>>> > wrote: >>>>>> >>>>>>> Yes, I need them to be buttons, styling problems, I need sth like: >>>>>>> >>>>>>> <button id="quick_search_form_submit" class=" ui-corner-all >>>>>>> ui-state-default" accesskey="s" type="submit" name=" >>>>>>> quick_search_form_submit"> >>>>>>> <span class="ui-icon left ui-icon-search"> </span> >>>>>>> Traži >>>>>>> </button> >>>>>>> >>>>>>> And that cannot be done with submit. >>>>>>> >>>>>>> However, this works for me: >>>>>>> >>>>>>> public function isChecked() >>>>>>> { >>>>>>> if (empty($this->getValue())) { >>>>>>> return true; >>>>>>> } >>>>>>> >>>>>>> return false; >>>>>>> } >>>>>>> >>>>>>> Regards, >>>>>>> Saša Stamenković >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Tue, Dec 22, 2009 at 5:50 PM, Hector Virgen >>>>>>> <[email protected]>wrote: >>>>>>> >>>>>>>> My apologies, you're right. I put together a quick test script and >>>>>>>> verified that button elements do not always return the correct result >>>>>>>> when >>>>>>>> calling isChecked(). In my test, using Chrome for Mac the button >>>>>>>> element did >>>>>>>> not return a value when submitted, which is required by isChecked(). >>>>>>>> >>>>>>>> However, I don't think this is entirely ZF's fault. >>>>>>>> >>>>>>>> According to w3schools.com, different browsers return different >>>>>>>> values when button elements are clicked. >>>>>>>> >>>>>>>> Important: If you use the button element in an HTML form, different >>>>>>>>> browsers will submit different values. Internet Explorer will submit >>>>>>>>> the >>>>>>>>> text between the <button> and </button> tags, while other browsers >>>>>>>>> will >>>>>>>>> submit the content of the value attribute. Use the >>>>>>>>> input<http://www.w3schools.com/tags/tag_input.asp> element >>>>>>>>> to create buttons in an HTML form. >>>>>>>> >>>>>>>> >>>>>>>> http://www.w3schools.com/tags/tag_button.asp >>>>>>>> >>>>>>>> <http://www.w3schools.com/tags/tag_button.asp>I suggest following >>>>>>>> their recommendation and using input elements instead of buttons, >>>>>>>> unless you >>>>>>>> absolutely need them to be buttons: >>>>>>>> >>>>>>>> $form->addElement('submit', 'go_submit', array( >>>>>>>> 'label' => 'Submit' >>>>>>>> )); >>>>>>>> >>>>>>>> I verified that submit elements do behave as expected when calling >>>>>>>> isChecked(). >>>>>>>> >>>>>>>> -- >>>>>>>> Hector >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Dec 21, 2009 at 11:21 PM, umpirsky <[email protected]>wrote: >>>>>>>> >>>>>>>>> О.К. I'm using buttons (type="submit"). >>>>>>>>> >>>>>>>>> Does for you this method returns opposite value then expected? >>>>>>>>> >>>>>>>>> Regards, >>>>>>>>> Saša Stamenković >>>>>>>>> >>>>>>>>> >>>>>>>>> On Mon, Dec 21, 2009 at 6:04 PM, Hector Virgen [via Zend Framework >>>>>>>>> Community] <[hidden >>>>>>>>> email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=976764&i=0> >>>>>>>>> > wrote: >>>>>>>>> >>>>>>>>>> That's because you can have two buttons with the same name but >>>>>>>>>> have different values. Only if the value matches will it be >>>>>>>>>> considered >>>>>>>>>> clicked. >>>>>>>>>> >>>>>>>>>> Also, with inputs (type=submit), the value and the label are the >>>>>>>>>> same thing. To make your button say "OK", its value should be "OK". >>>>>>>>>> When the >>>>>>>>>> button is clicked, the $_POST data will contain the value "OK" for >>>>>>>>>> the >>>>>>>>>> button. In ZF, that's why $element->setLabel() affects the value of >>>>>>>>>> the >>>>>>>>>> submit input. >>>>>>>>>> >>>>>>>>>> When it's not clicked, there may still be another input (hidden?) >>>>>>>>>> that sets the value to an empty string. This is why the label is >>>>>>>>>> tested >>>>>>>>>> against the value. >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Hector >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Mon, Dec 21, 2009 at 6:31 AM, umpirsky <[hidden >>>>>>>>>> email]<http://n4.nabble.com/user/SendEmail.jtp?type=node&node=976348&i=0> >>>>>>>>>> > wrote: >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Hi. >>>>>>>>>>> >>>>>>>>>>> For me, isChecked method works only after I set my buttons >>>>>>>>>>> (type="submit") >>>>>>>>>>> have same value for label and value attribs. >>>>>>>>>>> Also, it returns opposite value then expected, false when button >>>>>>>>>>> is clicked! >>>>>>>>>>> >>>>>>>>>>> Lets take a look at buton/submit isChecked method: >>>>>>>>>>> >>>>>>>>>>> /** >>>>>>>>>>> * Has this submit button been selected? >>>>>>>>>>> * >>>>>>>>>>> * @return bool >>>>>>>>>>> */ >>>>>>>>>>> public function isChecked() >>>>>>>>>>> { >>>>>>>>>>> $value = $this->getValue(); >>>>>>>>>>> >>>>>>>>>>> if (empty($value)) { >>>>>>>>>>> return false; >>>>>>>>>>> } >>>>>>>>>>> if ($value != $this->getLabel()) { >>>>>>>>>>> return false; >>>>>>>>>>> } >>>>>>>>>>> >>>>>>>>>>> return true; >>>>>>>>>>> } >>>>>>>>>>> >>>>>>>>>>> pretty odd, huh? I don't know why it is implemented this way, but >>>>>>>>>>> I patched >>>>>>>>>>> it to return opposite value, and it works now. Why label and >>>>>>>>>>> value need to >>>>>>>>>>> have same value at all? >>>>>>>>>>> >>>>>>>>>>> Anyone with same behaviour? >>>>>>>>>>> -- >>>>>>>>>>> View this message in context: >>>>>>>>>>> http://n4.nabble.com/Buttons-and-isChecked-method-tp976255p976255.html >>>>>>>>>>> Sent from the Zend Framework mailing list archive at Nabble.com. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> ------------------------------ >>>>>>>>> View this message in context: Re: [fw-general] Buttons and >>>>>>>>> isChecked >>>>>>>>> method<http://n4.nabble.com/Buttons-and-isChecked-method-tp976255p976764.html> >>>>>>>>> >>>>>>>>> Sent from the Zend Framework mailing list >>>>>>>>> archive<http://n4.nabble.com/Zend-Framework-f634138.html>at >>>>>>>>> Nabble.com. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >
