Issue Type: Improvement Created: 2008-06-30T13:23:37.000+0000 Last Updated: 2008-08-04T06:17:47.000+0000 Status: Postponed Fix version(s): Reporter: Zeljko Fedoran (arriu) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form
Related issues: Attachments:
Currently creating multiple radio button lists which belong to the same group (i.e. they should have the same "name" attribute) is rather difficult. This common requirement should not be this difficult to accomplish.
The problem starts in Zend_Form_Decorator_ViewHelper inside the render() function where the element name is given as the group name to the formRadio() function inside the Zend_View_Helper_FormRadio class. This is fine for most situations but if we have 2 or more radio lists which should belong to the same radio group in a Zend_Form object we have no way of setting it.
Even if one tries the logical approach and uses $element->setAttrib('name','some_group_name'); the name attribute is removed and not allowed to overwrite the default group name, which is derived from the element name.
Example Use-Case: A user needs to select a single category on a blog entry form. Lets assume each category can have a parent category. We start by listing the parent categories but will need to list all the subcategories underneath each parent category. Since the user should nly be able to select one category all listed categories should belong to the same group. This issue could be solved by having a fancy decorator and a single list but there may be other situations where it is desirable to have 2 or more lists which belong to the same group but are not tied to the same element object. The following image shows this concept: http://img242.imageshack.us/img242/9109/…
My solution to this issue was to update formRadio() by adding the following to the very top of the method before the _getInfo() call: $group = isset($attribs['name']) ? $attribs['name'] : $name;
Then i simply replaced $name with $group near the bottom where $radio is put together. This update allows me to call $element->setAttrib('name','some_group_name');
No comments to display
Have you found an issue?
See the Overview section for more details.