History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-3149
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matthew Weier O'Phinney
Reporter: Andreas Wenk
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Improvement for Zend_View ->

Created: 18/Apr/08 05:01 PM   Updated: 05/May/08 11:44 AM
Component/s: Zend_View
Affects Version/s: 1.5.1
Fix Version/s: 1.5.2

Time Tracking:
Original Estimate: 30 minutes
Original Estimate - 30 minutes
Remaining Estimate: 30 minutes
Remaining Estimate - 30 minutes
Time Spent: Not Specified
Remaining Estimate - 30 minutes

 Public Fields   Internal Project Management Fields   
Resolution Date: 25/Apr/08 04:15 PM
Fix Version Priority: Must Have


 Description  « Hide
In Zend Framework before 1.5 the Zend_View Helper FormCheckbox had the feature, that a hidden field with the value "0" was always set befor the checkbox. This was a very helpful feature because if you have a lot of checkboxes each with a boolean value which has to be to be stored in the database (e.g a char(1) DEFAULT '0'::bpchar in a postgres DB or SET '0','1' in a mysql DB) you want to have the value 0 if the checkbox is not checked. In the normal behaviour the checkbox value is not submitted if it is not checked.

It's really simple to make this improvement in FormCheckbox.php:

FormCheckbox.php
public function Checkbox($name, $value = null, $attribs = null) {
		
		$info = $this->_getInfo($name, $value, $attribs);
        extract($info); // name, id, value, attribs, options, listsep, disable
		
		// is the element checked?
        $checked = '';
        if (isset($attribs['checked']) && $attribs['checked']) {
            $checked = ' checked="checked"';
            unset($attribs['checked']);
        } elseif (isset($attribs['checked'])) {
            unset($attribs['checked']);
        }

        // is the element disabled?
        $disabled = '';
        if ($disable) {
            $disabled = ' disabled="disabled"';
        }

        // XHTML or HTML end tag?
        $endTag = ' />';
        if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
            $endTag= '>';
        }

        // build the element
        // ADDED: here we built the hidden field
         $xhtml .= '<input type="hidden"' 
        		. ' name="' . $this->view->escape($name) . '"'
        		. ' value="0"'
        		. $endTag; 
        		
        $xhtml .= '<input type="checkbox"'
               . ' name="' . $this->view->escape($name) . '"'
               . ' id="' . $this->view->escape($id) . '"'
               . ' value="' . $this->view->escape($value) . '"'
               . $checked
               . $disabled
               . $this->_htmlAttribs($attribs)
               . $endTag;
		
		return $xhtml;
	}

It would be cool to have that again in this Helper.

Andy



 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Wil Sinclair - 18/Apr/08 05:13 PM
Please evaluate and categorize/assign as necessary.

Matthew Weier O'Phinney - 22/Apr/08 10:55 AM
Scheduling for next mini release; this has affected many legacy apps.

Matthew Weier O'Phinney - 25/Apr/08 04:15 PM
Resolved in trunk and 1.5 release branch by r9324