Development

Changeset 19234

You must first sign up to be able to contribute.

Changeset 19234

Show
Ignore:
Timestamp:
06/13/09 18:17:54 (4 years ago)
Author:
joshiausdemwald
Message:

Packages

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfWidgetFormTreePlugin/lib/sfWidgetFormCheckboxTree.php

    r18792 r19234  
    7272    $this->addOption('value_key', false); 
    7373    $this->addOption('level_key', 'level'); 
     74    $this->addOption('hidden_nodes', false); 
    7475    $this->addOption('children_key', 'children'); 
    7576    $this->addOption('class', 'checkbox_tree'); 
     
    9798    } 
    9899    $choices = sfWidgetFormTree::normalizeChoices($this->getOption('choices'), $this->getOption('label_key'), $this->getOption('value_key'), $this->getOption('level_key'), $this->getOption('children_key')); 
     100    $hidden_nodes = $this->getOption('hidden_nodes'); 
     101    if($hidden_nodes !== false && !is_array($hidden_nodes)) 
     102      $hidden_nodes = array($hidden_nodes); 
     103 
    99104    if ($choices instanceof sfCallable) 
    100105    { 
    101106      $choices = $choices->call(); 
    102107    } 
    103     return $this->formatChoices($name, $value, $choices, $attributes);
     108    return $this->formatChoices($name, $value, $choices, $attributes, $hidden_nodes)
    104109  } 
    105110 
    106   protected function formatChoices($name, $value, $choices, $attributes
     111  protected function formatChoices($name, $value, $choices, $attributes, $hidden_nodes
    107112  { 
    108113    $inputs = array(); 
     
    111116      foreach($choices AS $key => $option) 
    112117      { 
     118        if(is_array($hidden_nodes) && in_array($key, $hidden_nodes)) 
     119          continue; 
    113120        if(!is_array($option)) throw new InvalidArgumentException(sprintf('Choice value must be an array, %s given.', gettype($option))); 
    114121        if(!isset($option[$this->getOption('label_key')])) throw new InvalidArgumentException(sprintf('Choice with key %s must have a label.', $key)); 
     
    132139          'input' => $this->renderTag('input', array_merge($baseAttributes, $attributes)), 
    133140          'label' => $this->renderContentTag('label', $option[$this->getOption('label_key')], array('for' => $id_attr)), 
    134           'children' => isset($option['children']) ? $this->formatChoices($name, $value, $option['children'], $attributes) : null 
     141          'children' => isset($option['children']) ? $this->formatChoices($name, $value, $option['children'], $attributes, $hidden_nodes) : null 
    135142        ); 
    136143      } 
  • plugins/sfWidgetFormTreePlugin/lib/sfWidgetFormRadioTree.php

    r18797 r19234  
    7272    $this->addOption('value_key', false); 
    7373    $this->addOption('level_key', 'level'); 
     74    $this->addOption('hidden_nodes', false); 
    7475    $this->addOption('children_key', 'children'); 
    7576    $this->addOption('class', 'radio_tree'); 
     
    9394  { 
    9495    $choices = sfWidgetFormTree::normalizeChoices($this->getOption('choices'), $this->getOption('label_key'), $this->getOption('value_key'), $this->getOption('level_key'), $this->getOption('children_key')); 
     96    $hidden_nodes = $this->getOption('hidden_nodes'); 
     97    if($hidden_nodes !== false && !is_array($hidden_nodes)) 
     98      $hidden_nodes = array($hidden_nodes); 
     99       
    95100    if ($choices instanceof sfCallable) 
    96101    { 
    97102      $choices = $choices->call(); 
    98103    } 
    99     return $this->formatChoices($name, $value, $choices, $attributes);
     104    return $this->formatChoices($name, $value, $choices, $attributes, $hidden_nodes)
    100105  } 
    101106 
    102   protected function formatChoices($name, $value, $choices, $attributes
     107  protected function formatChoices($name, $value, $choices, $attributes, $hidden_nodes
    103108  { 
    104109    $inputs = array(); 
     
    107112      foreach($choices AS $key => $option) 
    108113      { 
     114        if(is_array($hidden_nodes)  && in_array($key, $hidden_nodes)) 
     115          continue; 
     116 
    109117        if(!is_array($option)) throw new InvalidArgumentException(sprintf('Choice value must be an array, %s given.', gettype($option))); 
    110118        if(!isset($option[$this->getOption('label_key')])) throw new InvalidArgumentException(sprintf('Choice with key %s must have a label.', $key)); 
     
    128136          'input' => $this->renderTag('input', array_merge($baseAttributes, $attributes)), 
    129137          'label' => $this->renderContentTag('label', $option[$this->getOption('label_key')], array('for' => $id_attr)), 
    130           'children' => isset($option['children']) ? $this->formatChoices($name, $value, $option['children'], $attributes) : null 
     138          'children' => isset($option['children']) ? $this->formatChoices($name, $value, $option['children'], $attributes, $hidden_nodes) : null 
    131139        ); 
    132140      } 
  • plugins/sfWidgetFormTreePlugin/lib/sfWidgetFormTree.php

    r18797 r19234  
    7272    $this->addOption('value_key', false); 
    7373    $this->addOption('level_key', 'level'); 
     74    $this->addOption('hidden_nodes', false); 
    7475    $this->addOption('children_key', 'children'); 
    7576    $this->addOption('multiple', false); 
     
    145146      $class = sprintf('sfWidgetForm%sTree', ucfirst($type)); 
    146147    } 
    147     return new $class(array_merge(array('value_key'=>$this->getOption('value_key'), 'label_key'=>$this->getOption('label_key'), 'level_key'=>$this->getOption('level_key'), 'children_key'=>$this->getOption('children_key'), 'choices' => new sfCallable(array($this, 'getChoices'))), $this->options['renderer_options']), $this->getAttributes()); 
     148    return new $class(array_merge(array('hidden_nodes'=>$this->getOption('hidden_nodes'), 'value_key'=>$this->getOption('value_key'), 'label_key'=>$this->getOption('label_key'), 'level_key'=>$this->getOption('level_key'), 'children_key'=>$this->getOption('children_key'), 'choices' => new sfCallable(array($this, 'getChoices'))), $this->options['renderer_options']), $this->getAttributes()); 
    148149  } 
    149150