Development

Changeset 8946

You must first sign up to be able to contribute.

Changeset 8946

Show
Ignore:
Timestamp:
05/14/08 08:11:07 (5 months ago)
Author:
nicolas
Message:

Added a sfWidgetFormSchema::setDefaultFormFormatterName() method which allow to set a static default formatter name

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/widget/sfWidgetFormSchema.class.php

    r8756 r8946  
    2626    BEFORE = 'before', 
    2727    AFTER  = 'after'; 
     28   
     29  protected static 
     30    $defaultFormatterName = 'table'; 
    2831 
    2932  protected 
     
    6366 
    6467    $this->addOption('name_format', '%s'); 
    65     $this->addOption('form_formatter', 'table'); 
     68    $this->addOption('form_formatter', self::$defaultFormatterName); 
    6669 
    6770    parent::__construct($options, $attributes); 
     
    99102  { 
    100103    return $this->formFormatters; 
     104  } 
     105   
     106  /** 
     107   * Sets the generic default formatter name used by the class. If you want all  
     108   * of your forms to be generated with the <code>list</code> format, you can  
     109   * do it in a project or application configuration class: 
     110   *  
     111   * <pre> 
     112   * class ProjectConfiguration extends sfProjectConfiguration 
     113   * { 
     114   *   public function setup() 
     115   *   { 
     116   *     sfWidgetFormSchema::setDefaultFormFormatterName('list'); 
     117   *   } 
     118   * } 
     119   * </pre>   
     120   * 
     121   * @param string $name 
     122   */ 
     123  static public function setDefaultFormFormatterName($name) 
     124  { 
     125    self::$defaultFormatterName = $name; 
    101126  } 
    102127 
  • branches/1.1/test/unit/widget/sfWidgetFormSchemaTest.php

    r8756 r8946  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(57, new lime_output_color()); 
     13$t = new lime_test(59, new lime_output_color()); 
    1414 
    1515$w1 = new sfWidgetFormInput(array(), array('class' => 'foo1')); 
     
    332332  $t->ok($widget == $f[$name], '__clone() clones embedded widgets'); 
    333333} 
     334 
     335// setDefaultFormFormatterName() 
     336$t->diag('setDefaultFormFormatterName()'); 
     337$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2)); 
     338$t->isa_ok($w->getFormFormatter(), 'sfWidgetFormSchemaFormatterTable', 'setDefaultFormFormatterName() has the "sfWidgetFormSchemaFormatterTable" form formatter by default'); 
     339 
     340sfWidgetFormSchema::setDefaultFormFormatterName('list'); 
     341$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2)); 
     342$t->isa_ok($w->getFormFormatter(), 'sfWidgetFormSchemaFormatterList', 'setDefaultFormFormatterName() changes the default form formatter name correctly');