Development

#5113: patch.patch

You must first sign up to be able to contribute.

Ticket #5113: patch.patch

File patch.patch, 0.9 kB (added by Wicked, 1 year ago)

Optimization patch for the options_for_select()

  • FormHelper.php

    old new  
    5858{ 
    5959  $html_options = _parse_attributes($html_options); 
    6060 
    61   if (is_array($selected)) 
     61  if (!is_array($selected)) 
    6262  { 
    63     $selected = array_map('strval', array_values($selected)); 
     63    $selected = array($seleted); 
    6464  } 
    6565 
     66  $selected = array_map('strval', array_values($selected)); 
     67  $selected_set = array_flip($selected); 
     68 
    6669  $html = ''; 
    6770 
    6871  if ($value = _get_option($html_options, 'include_custom')) 
     
    8487    { 
    8588      $option_options = array('value' => $key); 
    8689 
    87       if ( 
    88           (is_array($selected) && in_array(strval($key), $selected, true)) 
    89           || 
    90           (strval($key) == strval($selected)) 
    91          ) 
    92       { 
     90      if (isset($selected_set[strval($key)])) { 
    9391        $option_options['selected'] = 'selected'; 
    9492      } 
    9593 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.