Changeset 1458

Show
Ignore:
Timestamp:
12/07/2007 05:37:16 PM (10 months ago)
Author:
Shadowhand
Message:

Updated Form_Checkbox output format: <label>$input.$label</label>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/forge/libraries/Form_Checkbox.php

    r1439 r1458  
    2424        } 
    2525 
     26        public function label($val = NULL) 
     27        { 
     28                if ($val === NULL) 
     29                { 
     30                        return ''; 
     31                } 
     32                else 
     33                { 
     34                        $this->data['label'] = ($val === TRUE) ? ucwords(inflector::humanize($this->name)) : $val; 
     35                        return $this; 
     36                } 
     37        } 
     38 
    2639        protected function html_element() 
    2740        { 
    28                 // Get the  
     41                // Import the data 
    2942                $data = $this->data; 
    3043 
    31                 // Remove label 
    32                 unset($data['label']); 
     44                if ($label = arr::remove('label', $data)) 
     45                { 
     46                        // There must be one space before the text 
     47                        $label = ' '.ltrim($label); 
     48                } 
    3349 
    34                 return form::checkbox($data); 
     50                return '<label>'.form::checkbox($data).$label.'</label>'; 
    3551        } 
    3652