Changeset 8946
- Timestamp:
- 05/14/08 08:11:07 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/widget/sfWidgetFormSchema.class.php
r8756 r8946 26 26 BEFORE = 'before', 27 27 AFTER = 'after'; 28 29 protected static 30 $defaultFormatterName = 'table'; 28 31 29 32 protected … … 63 66 64 67 $this->addOption('name_format', '%s'); 65 $this->addOption('form_formatter', 'table');68 $this->addOption('form_formatter', self::$defaultFormatterName); 66 69 67 70 parent::__construct($options, $attributes); … … 99 102 { 100 103 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; 101 126 } 102 127 branches/1.1/test/unit/widget/sfWidgetFormSchemaTest.php
r8756 r8946 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(5 7, new lime_output_color());13 $t = new lime_test(59, new lime_output_color()); 14 14 15 15 $w1 = new sfWidgetFormInput(array(), array('class' => 'foo1')); … … 332 332 $t->ok($widget == $f[$name], '__clone() clones embedded widgets'); 333 333 } 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 340 sfWidgetFormSchema::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');