Changeset 243

Show
Ignore:
Timestamp:
08/22/06 23:25:24 (6 years ago)
Author:
john
Message:

fixed select multiple to add brackets

Location:
trunk/trax/vendor/trax/action_view/helpers
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/action_view/helpers/form_helper.php

    r233 r243  
    130130     *  @uses tag_name_with_index() 
    131131     */ 
    132     function add_default_name_and_id($options) {     
     132    function add_default_name_and_id($options) {   
     133        $name_option_exists = array_key_exists('name', $options);    
    133134        if(array_key_exists("index", $options)) { 
    134             $options["name"] = array_key_exists("name", $options) 
    135                 ? $options["name"] 
    136                 : $this->tag_name_with_index($options["index"]); 
    137             $options["id"] = array_key_exists("id", $options) 
    138                 ? $options["id"] 
    139                 : $this->tag_id_with_index($options["index"]); 
    140             unset($options["index"]); 
     135            $options['name'] = $name_option_exists 
     136                ? $options['name'] 
     137                : $this->tag_name_with_index($options['index']); 
     138            $options['id'] = array_key_exists('id', $options) 
     139                ? $options['id'] 
     140                : $this->tag_id_with_index($options['index']); 
     141            unset($options['index']); 
    141142        } elseif($this->auto_index) { 
    142             $options["name"] = array_key_exists("name", $options) 
    143                 ? $options["name"] 
     143            $options['name'] = $name_option_exists 
     144                ? $options['name'] 
    144145                : $this->tag_name_with_index($this->auto_index); 
    145             $options["id"] = array_key_exists("id", $options) 
    146                 ? $options["id"] 
     146            $options['id'] = array_key_exists('id', $options) 
     147                ? $options['id'] 
    147148                : $this->tag_id_with_index($this->auto_index); 
    148149        } else { 
    149             $options["name"] = array_key_exists("name", $options) 
    150                 ? $options["name"] 
     150            $options['name'] = $name_option_exists 
     151                ? $options['name'] 
    151152                : $this->tag_name(); 
    152             $options["id"] = array_key_exists("id", $options) 
    153                 ? $options["id"] 
     153            $options['id'] = array_key_exists('id', $options) 
     154                ? $options['id'] 
    154155                : $this->tag_id(); 
     156        } 
     157        if(array_key_exists('multiple', $options) && !$name_option_exists) { 
     158            $options['name'] .= "[]";            
    155159        } 
    156160        return $options; 
     
    232236        return $this->error_wrapping( 
    233237           $this->content_tag("textarea", 
    234                               htmlspecialchars($this->value()), 
     238                              htmlspecialchars($this->value(), ENT_COMPAT), 
    235239                              $options), 
    236240           array_key_exists($this->attribute_name,$this->object()->errors) 
  • trunk/trax/vendor/trax/action_view/helpers/form_options_helper.php

    r233 r243  
    208208                 $this->add_options( 
    209209                           $this->options_for_select($choices, $value), 
    210                            $options, 
    211                            $value), 
     210                           $options), 
    212211                 $html_options), 
    213212             $this->object()->errors[$this->attribute_name]); 
     
    237236                        $attribute_text, 
    238237                        $value), 
    239                     $options, 
    240                     $value), 
     238                    $options), 
    241239                $html_options), 
    242240            $this->object()->errors[$this->attribute_name]); 
     
    261259                        $this->country_options_for_select($value, 
    262260                                                          $priority_countries), 
    263                         $options, 
    264                         $value), 
     261                        $options), 
    265262                $html_options), 
    266263            $this->object()->errors[$this->attribute_name]); 
     
    271268     * 
    272269     *  @param string 
    273      *  @param string[] 
    274      *  @param string 
    275      *  @uses value() 
    276      */ 
    277     private function add_options($option_tags, $options, $value = null) { 
     270     *  @param array 
     271     */ 
     272    private function add_options($option_tags, $options) { 
    278273        if(array_key_exists("include_blank", $options) 
    279274           && $options["include_blank"] == true) { 
    280275            $option_tags = "<option value=\"\"></option>\n" . $option_tags; 
    281276        }  
    282         if(empty($value) && array_key_exists('prompt', $options)) { 
     277        if(array_key_exists('prompt', $options)) { 
    283278            $text = $options['prompt'] ? $options['prompt'] : "Please select"; 
    284279            return ("<option value=\"\">$text</option>\n" . $option_tags);