Changeset 7053
- Timestamp:
- 01/14/08 19:57:07 (10 months ago)
- Files:
-
- branches/1.1/lib/form/sfForm.class.php (modified) (5 diffs)
- branches/1.1/lib/validator/sfValidatorSchema.class.php (modified) (3 diffs)
- branches/1.1/lib/widget/sfWidgetFormSchema.class.php (modified) (7 diffs)
- branches/1.1/lib/widget/sfWidgetFormSchemaDecorator.class.php (modified) (1 diff)
- branches/1.1/lib/widget/sfWidgetFormSchemaForEach.class.php (modified) (3 diffs)
- branches/1.1/test/unit/form/sfFormFieldTest.php (modified) (1 diff)
- branches/1.1/test/unit/form/sfFormTest.php (modified) (8 diffs)
- branches/1.1/test/unit/validator/sfValidatorSchemaTest.php (modified) (7 diffs)
- branches/1.1/test/unit/widget/sfWidgetFormSchemaDecoratorTest.php (modified) (1 diff)
- branches/1.1/test/unit/widget/sfWidgetFormSchemaForEachTest.php (modified) (2 diffs)
- branches/1.1/test/unit/widget/sfWidgetFormSchemaTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/form/sfForm.class.php
r7051 r7053 208 208 * @param string The field name 209 209 * @param sfForm A sfForm instance 210 * @param string The format to use for widget name211 210 * @param string A HTML decorator for the embedded form 212 211 */ 213 public function embedForm($name, sfForm $form, $nameFormat = null, $decorator = null) 214 { 215 // change the name format for the embedded widget 216 if (is_null($nameFormat)) 217 { 218 $nameFormat = $this->generateNameFormatForEmbedded($name, $this->widgetSchema->getNameFormat()); 219 } 220 212 public function embedForm($name, sfForm $form, $decorator = null) 213 { 221 214 $form = clone $form; 222 215 unset($form[self::$CSRFFieldName]); 223 216 224 217 $widgetSchema = $form->getWidgetSchema(); 225 $widgetSchema->setNameFormat($nameFormat);226 218 227 219 $this->setDefault($name, $form->getDefaults()); … … 240 232 * @param string The field name 241 233 * @param sfForm A sfForm instance 242 * @param integer The number of times to include the form 243 * @param string The format to use for widget name 234 * @param integer The number of times to embed the form 244 235 * @param string A HTML decorator for the main form around embedded forms 245 236 * @param string A HTML decorator for each embedded form 246 237 */ 247 public function embedFormForEach($name, sfForm $form, $n, $nameFormat = null, $decorator = null, $innerDecorator = null, $attributes = array(), $options = array(), $labels = array()) 248 { 249 // change the name format for the embedded widget 250 if (is_null($nameFormat)) 251 { 252 $nameFormat = $this->generateNameFormatForEmbedded($name, $this->widgetSchema->getNameFormat()); 253 } 254 238 public function embedFormForEach($name, sfForm $form, $n, $decorator = null, $innerDecorator = null, $attributes = array(), $options = array(), $labels = array()) 239 { 255 240 $form = clone $form; 256 241 unset($form[self::$CSRFFieldName]); 242 243 $widgetSchema = $form->getWidgetSchema(); 257 244 258 245 // generate labels and default values … … 262 249 if (!isset($labels[$i])) 263 250 { 264 $labels[$i] = sprintf('%s (%s)', $ form->getWidgetSchema()->generateLabelName($name), $i);251 $labels[$i] = sprintf('%s (%s)', $widgetSchema->generateLabelName($name), $i); 265 252 } 266 253 … … 270 257 $this->setDefault($name, $defaults); 271 258 272 $decorator = is_null($decorator) ? $ form->getWidgetSchema()->getFormFormatter()->getDecoratorFormat() : $decorator;273 $innerDecorator = is_null($innerDecorator) ? $ form->getWidgetSchema()->getFormFormatter()->getDecoratorFormat() : $innerDecorator;274 275 $this->widgetSchema[$name] = new sfWidgetFormSchemaDecorator(new sfWidgetFormSchemaForEach( $nameFormat, new sfWidgetFormSchemaDecorator($form->getWidgetSchema(), $innerDecorator), $n, $attributes, $options, $labels), $decorator);259 $decorator = is_null($decorator) ? $widgetSchema->getFormFormatter()->getDecoratorFormat() : $decorator; 260 $innerDecorator = is_null($innerDecorator) ? $widgetSchema->getFormFormatter()->getDecoratorFormat() : $innerDecorator; 261 262 $this->widgetSchema[$name] = new sfWidgetFormSchemaDecorator(new sfWidgetFormSchemaForEach(new sfWidgetFormSchemaDecorator($widgetSchema, $innerDecorator), $n, $attributes, $options, $labels), $decorator); 276 263 $this->validatorSchema[$name] = new sfValidatorSchemaForEach($form->getValidatorSchema(), $n); 277 264 … … 621 608 622 609 return $this->formField; 623 }624 625 /**626 * Generates a name format for embedded forms.627 *628 * @param string The widget name629 * @param string The current name format630 *631 * @return string The name format to use for embedding632 *633 * @see embedFormForEach()634 * @see embedForm()635 */636 protected function generateNameFormatForEmbedded($name, $nameFormat)637 {638 // if current name format is something[%s], change it to something[$name][%s]639 // else change it to $name[%s]640 if ('[%s]' === substr($nameFormat, -4))641 {642 return sprintf('%s[%s][%%s]', substr($nameFormat, 0, -4), $name);643 }644 else645 {646 return sprintf('%s[%%s]', $name);647 }648 610 } 649 611 branches/1.1/lib/validator/sfValidatorSchema.class.php
r7052 r7053 245 245 public function setPreValidator(sfValidator $validator) 246 246 { 247 $this->preValidator = $validator;247 $this->preValidator = clone $validator; 248 248 } 249 249 … … 265 265 public function setPostValidator(sfValidator $validator) 266 266 { 267 $this->postValidator = $validator;267 $this->postValidator = clone $validator; 268 268 } 269 269 … … 315 315 } 316 316 317 $this->fields[$name] = $validator;317 $this->fields[$name] = clone $validator; 318 318 } 319 319 branches/1.1/lib/widget/sfWidgetFormSchema.class.php
r7051 r7053 28 28 29 29 protected 30 $parent = null, 30 31 $formFormatters = array(), 31 32 $options = array(), … … 58 59 public function __construct($fields = null, $options = array(), $attributes = array(), $labels = array(), $helps = array()) 59 60 { 60 if (is_array($fields))61 {62 foreach ($fields as $name => $widget)63 {64 $this[$name] = $widget;65 }66 }67 else if (!is_null($fields))68 {69 throw new InvalidArgumentException('sfWidgetFormSchema constructor takes an array of sfWidget objects.');70 }71 72 61 $this->labels = $labels; 73 62 $this->helps = $helps; … … 77 66 78 67 parent::__construct($options, $attributes); 68 69 if (is_array($fields)) 70 { 71 foreach ($fields as $name => $widget) 72 { 73 $this[$name] = $widget; 74 } 75 } 76 else if (!is_null($fields)) 77 { 78 throw new InvalidArgumentException('sfWidgetFormSchema constructor takes an array of sfWidget objects.'); 79 } 79 80 } 80 81 … … 152 153 public function setNameFormat($format) 153 154 { 155 if (false !== $format && false === strpos($format, '%s')) 156 { 157 throw new InvalidArgumentException(sprintf('The name format must contain %%s ("%s" given)', $format)); 158 } 159 154 160 $this->options['name_format'] = $format; 155 161 } … … 414 420 public function generateName($name) 415 421 { 416 if (false === $this->options['name_format']) 417 { 418 return $name; 419 } 420 421 if (false !== strpos($this->options['name_format'], '%s')) 422 { 423 return sprintf($this->options['name_format'], $name); 422 $format = $this->getNameFormat(); 423 424 if ('[%s]' == substr($format, -4)) 425 { 426 if (preg_match('/^(.+?)\[(.+)\]$/', $name, $match)) 427 { 428 $name = sprintf('%s[%s][%s]', substr($format, 0, -4), $match[1], $match[2]); 429 } 430 else 431 { 432 $name = sprintf('%s[%s]', substr($format, 0, -4), $name); 433 } 434 } 435 else if (false !== $format) 436 { 437 $name = sprintf($format, $name); 438 } 439 440 if ($parent = $this->getParent()) 441 { 442 $name = $parent->generateName($name); 424 443 } 425 444 426 445 return $name; 446 } 447 448 /** 449 * Gets the parent widget schema. 450 * 451 * @return sfWidgetFormSchema The parent widget schema 452 */ 453 public function getParent() 454 { 455 return $this->parent; 456 } 457 458 /** 459 * Sets the parent widget schema. 460 * 461 * @parent sfWidgetFormSchema The parent widget schema 462 */ 463 public function setParent(sfWidgetFormSchema $parent = null) 464 { 465 $this->parent = $parent; 427 466 } 428 467 … … 469 508 } 470 509 471 $this->fields[$name] = $widget; 510 $this->fields[$name] = clone $widget; 511 512 if ($widget instanceof sfWidgetFormSchema) 513 { 514 $this->fields[$name]->setParent($this); 515 $this->fields[$name]->setNameFormat($name.'[%s]'); 516 } 472 517 } 473 518 … … 596 641 foreach ($this->fields as $name => $field) 597 642 { 598 $this->fields[$name] = clone $field; 643 // offsetSet will clone the field and change the parent 644 $this[$name] = $field; 599 645 } 600 646 } branches/1.1/lib/widget/sfWidgetFormSchemaDecorator.class.php
r7046 r7053 228 228 * @see sfWidgetFormSchema 229 229 */ 230 public function setParent(sfWidgetFormSchema $parent )230 public function setParent(sfWidgetFormSchema $parent = null) 231 231 { 232 232 $this->widget->setParent($parent); branches/1.1/lib/widget/sfWidgetFormSchemaForEach.class.php
r5937 r7053 10 10 11 11 /** 12 * 12 * sfWidgetFormSchemaForEach duplicates a given widget multiple times in a widget schema. 13 13 * 14 14 * @package symfony … … 22 22 * Constructor. 23 23 * 24 * @param string The name format string25 24 * @param sfWidgetFormSchema A sfWidgetFormSchema instance 26 * @param integer The number of times to replicate the widget25 * @param integer The number of times to duplicate the widget 27 26 * @param array An array of options 28 27 * @param array An array of default HTML attributes … … 31 30 * @see sfWidgetFormSchema 32 31 */ 33 public function __construct( $nameFormat,sfWidgetFormSchema $widget, $count, $options = array(), $attributes = array(), $labels = array())32 public function __construct(sfWidgetFormSchema $widget, $count, $options = array(), $attributes = array(), $labels = array()) 34 33 { 35 $fields = array(); 36 for ($i = 0; $i < $count; $i++) 37 { 38 $clone = clone $widget; 39 $clone->setNameFormat(sprintf($nameFormat, $i).'[%s]'); 40 41 $fields[$i] = $clone; 42 } 43 44 parent::__construct($fields, $options, $attributes, $labels); 34 parent::__construct(array_fill(0, $count, $widget), $options, $attributes, $labels); 45 35 } 46 36 } branches/1.1/test/unit/form/sfFormFieldTest.php
r7047 r7053 39 39 // ->getValue() ->getWidget() ->getParent() ->getError() ->hasError() 40 40 $t->diag('->getValue() ->getWidget() ->getParent() ->getError() ->hasError()'); 41 $t-> is($f->getWidget(),$titleWidget, '->getWidget() returns the form field widget');41 $t->ok($f->getWidget() == $titleWidget, '->getWidget() returns the form field widget'); 42 42 $t->is($f->getValue(), 'symfony', '->getValue() returns the form field value'); 43 43 $t->is($f->getParent(), $parent, '->getParent() returns the form field parent'); branches/1.1/test/unit/form/sfFormTest.php
r7051 r7053 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(8 2, new lime_output_color());13 $t = new lime_test(83, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 18 18 { 19 19 return "*$secret*"; 20 }21 22 public function generateNameFormatForEmbedded($name, $nameFormat)23 {24 return parent::generateNameFormatForEmbedded($name, $nameFormat);25 20 } 26 21 } … … 117 112 $f->setValidators($validators); 118 113 $schema = $f->getValidatorSchema(); 119 $t-> is_deeply($schema['first_name'],$validators['first_name'], '->setValidators() sets field validators');120 $t-> is_deeply($schema['last_name'],$validators['last_name'], '->setValidators() sets field validators');114 $t->ok($schema['first_name'] == $validators['first_name'], '->setValidators() sets field validators'); 115 $t->ok($schema['last_name'] == $validators['last_name'], '->setValidators() sets field validators'); 121 116 122 117 // ->setWidgets() ->setWidgetSchema() ->getWidgetSchema() … … 129 124 $widgetSchema = new sfWidgetFormSchema($widgets); 130 125 $f->setWidgetSchema($widgetSchema); 131 $t-> is_deeply($f->getWidgetSchema(),$widgetSchema, '->setWidgetSchema() sets the current widget schema');126 $t->ok($f->getWidgetSchema() == $widgetSchema, '->setWidgetSchema() sets the current widget schema'); 132 127 $f->setWidgets($widgets); 133 128 $schema = $f->getWidgetSchema(); 134 $t-> is_deeply($schema['first_name'],$widgets['first_name'], '->setWidgets() sets field widgets');135 $t-> is_deeply($schema['last_name'],$widgets['last_name'], '->setWidgets() sets field widgets');129 $t->ok($schema['first_name'] == $widgets['first_name'], '->setWidgets() sets field widgets'); 130 $t->ok($schema['last_name'] == $widgets['last_name'], '->setWidgets() sets field widgets'); 136 131 137 132 // ArrayAccess interface … … 220 215 $t->is($f->getErrorSchema()->getCode(), '1 [min_length] file [max_size]', '->bind() behaves correctly with files'); 221 216 222 // ->generateNameFormatForEmbedded()223 $t->diag('->generateNameFormatForEmbedded()');224 $f = new FormTest();225 $t->is($f->generateNameFormatForEmbedded('article', '%s'), 'article[%s]', '->generateNameFormatForEmbedded() generates a name format for an embed form');226 $t->is($f->generateNameFormatForEmbedded('author', 'article[%s]'), 'article[author][%s]', '->generateNameFormatForEmbedded() generates a name format for an embed form');227 228 217 // ->embedForm() 229 218 $t->diag('->embedForm()'); 219 230 220 $author = new FormTest(array('first_name' => 'Fabien')); 231 221 $author->setWidgetSchema($author_widget_schema = new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInput()))); 232 222 $author->setValidatorSchema($author_validator_schema = new sfValidatorSchema(array('first_name' => new sfValidatorString(array('min_length' => 2))))); 223 224 $company = new FormTest(); 225 $company->setWidgetSchema($company_widget_schema = new sfWidgetFormSchema(array('name' => new sfWidgetFormInput()))); 226 $company->setValidatorSchema($company_validator_schema = new sfValidatorSchema(array('name' => new sfValidatorString(array('min_length' => 2))))); 227 233 228 $article = new FormTest(); 234 229 $article->setWidgetSchema($article_widget_schema = new sfWidgetFormSchema(array('title' => new sfWidgetFormInput()))); 235 230 $article->setValidatorSchema($article_validator_schema = new sfValidatorSchema(array('title' => new sfValidatorString(array('min_length' => 2))))); 236 231 232 $author->embedForm('company', $company); 237 233 $article->embedForm('author', $author); 238 234 $v = $article->getValidatorSchema(); 239 235 $w = $article->getWidgetSchema(); 240 236 $d = $article->getDefaults(); 237 238 $w->setNameFormat('article[%s]'); 241 239 242 240 $t->ok($v['author']['first_name'] == $author_validator_schema['first_name'], '->embedForm() embeds the validator schema'); … … 245 243 $t->is($v['author'][sfForm::getCSRFFieldName()], null, '->embedForm() removes the CSRF token for the embedded form'); 246 244 $t->is($w['author'][sfForm::getCSRFFieldName()], null, '->embedForm() removes the CSRF token for the embedded form'); 245 246 $t->is($w['author']->generateName('first_name'), 'article[author][first_name]', '->embedForm() changes the name format to reflect the embedding'); 247 $t->is($w['author']['company']->generateName('name'), 'article[author][company][name]', '->embedForm() changes the name format to reflect the embedding'); 247 248 248 249 // ->embedFormForEach() … … 252 253 $w = $article->getWidgetSchema(); 253 254 $d = $article->getDefaults(); 255 $w->setNameFormat('article[%s]'); 254 256 255 257 for ($i = 0; $i < 2; $i++) … … 261 263 $t->is($w['authors'][$i][sfForm::getCSRFFieldName()], null, '->embedFormForEach() removes the CSRF token for the embedded forms'); 262 264 } 265 266 $t->is($w['authors'][0]->generateName('first_name'), 'article[authors][0][first_name]', '->embedFormForEach() changes the name format to reflect the embedding'); 263 267 264 268 // ::convertFileInformation() branches/1.1/test/unit/validator/sfValidatorSchemaTest.php
r7052 r7053 88 88 89 89 $v = new sfValidatorSchema(array('s1' => $v1)); 90 $t-> is($v['s1'],$v1, 'sfValidatorSchema implements the ArrayAccess interface for the fields');90 $t->ok($v['s1'] == $v1, 'sfValidatorSchema implements the ArrayAccess interface for the fields'); 91 91 $t->is($v['s2'], null, 'sfValidatorSchema implements the ArrayAccess interface for the fields'); 92 92 … … 161 161 $v = new sfValidatorSchema(array('s1' => $v1, 's2' => $v2)); 162 162 $v->setPreValidator($preValidator = new PreValidator()); 163 $t-> is($v->getPreValidator(),$preValidator, '->getPreValidator() returns the current pre validator');163 $t->ok($v->getPreValidator() == $preValidator, '->getPreValidator() returns the current pre validator'); 164 164 try 165 165 { … … 181 181 $v = new sfValidatorSchema(array('s1' => $v1, 's2' => $v2)); 182 182 $v->setPostValidator($postValidator = new PostValidator()); 183 $t-> is($v->getPostValidator(),$postValidator, '->getPostValidator() returns the current post validator');183 $t->ok($v->getPostValidator() == $postValidator, '->getPostValidator() returns the current post validator'); 184 184 $t->is($v->clean(array('s1' => 'foo', 's2' => 'bar')), array('s1' => '*foo*', 's2' => '*bar*'), '->clean() executes post validators'); 185 185 … … 221 221 222 222 $t->diag('one validator fails'); 223 $v 2->setOption('max_length', 2);223 $v['s2']->setOption('max_length', 2); 224 224 try 225 225 { … … 236 236 237 237 $t->diag('several validators fail'); 238 $v 1->setOption('max_length', 2);239 $v 2->setOption('max_length', 2);238 $v['s1']->setOption('max_length', 2); 239 $v['s2']->setOption('max_length', 2); 240 240 try 241 241 { … … 269 269 270 270 $t->diag('postValidator throws global errors'); 271 $comparator->setOption('throw_global_error', true); 271 foreach (array($userValidator->getPostValidator(), $v->getPostValidator(), $v['embedded']->getPostValidator()) as $validator) 272 { 273 $validator->setOption('throw_global_error', true); 274 } 272 275 try 273 276 { … … 287 290 288 291 $t->diag('postValidator throws named errors'); 289 $comparator->setOption('throw_global_error', false); 292 foreach (array($userValidator->getPostValidator(), $v->getPostValidator(), $v['embedded']->getPostValidator()) as $validator) 293 { 294 $validator->setOption('throw_global_error', false); 295 } 290 296 try 291 297 { branches/1.1/test/unit/widget/sfWidgetFormSchemaDecoratorTest.php
r7051 r7053 58 58 59 59 $w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>"); 60 $t-> is($w['w1'],$w1, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields');61 $t-> is($w['w2'],$w2, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields');62 $t-> is($ws['w1'],$w1, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields');63 $t-> is($ws['w2'],$w2, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields');60 $t->ok($w['w1'] == $w1, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 61 $t->ok($w['w2'] == $w2, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 62 $t->ok($ws['w1'] == $w1, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 63 $t->ok($ws['w2'] == $w2, 'sfWidgetFormSchemaDecorator implements the ArrayAccess interface for the fields'); 64 64 65 65 $w = new sfWidgetFormSchemaDecorator($ws, "<table>\n%content%</table>"); branches/1.1/test/unit/widget/sfWidgetFormSchemaForEachTest.php
r5937 r7053 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 1, new lime_output_color());13 $t = new lime_test(4, new lime_output_color()); 14 14 15 15 $w1 = new sfWidgetFormInput(); … … 18 18 // __construct() 19 19 $t->diag('__construct()'); 20 $wf = new sfWidgetFormSchemaForEach('article[%s]', $w, 2); 21 $wc1 = clone $w; 22 $wc1->setNameFormat('article[0][%s]'); 23 $wc2 = clone $w; 24 $wc2->setNameFormat('article[1][%s]'); 25 $t->is($wf->getFields(), array($wc1, $wc2), '__construct() takes a sfWidgetFormSchema as its second argument'); 20 $wf = new sfWidgetFormSchemaForEach($w, 2); 21 $t->ok($wf[0]['w1'] !== $w1, '__construct() takes a sfWidgetFormSchema as its first argument'); 22 $t->ok($wf[0]['w1'] == $w1, '__construct() takes a sfWidgetFormSchema as its first argument'); 23 $t->ok($wf[1]['w1'] !== $w1, '__construct() takes a sfWidgetFormSchema as its first argument'); 24 $t->ok($wf[1]['w1'] == $w1, '__construct() takes a sfWidgetFormSchema as its first argument'); branches/1.1/test/unit/widget/sfWidgetFormSchemaTest.php
r7051 r7053 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(5 5, 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')); … … 62 62 63 63 $w = new sfWidgetFormSchema(array('w1' => $w1)); 64 $t-> is($w['w1'],$w1, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields');64 $t->ok($w['w1'] == $w1, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); 65 65 $t->is($w['w2'], null, 'sfWidgetFormSchema implements the ArrayAccess interface for the fields'); 66 66 … … 103 103 $t->is($w->getNameFormat(), 'article[%s]', '->getNameFormat() returns the name format'); 104 104 105 $w->setNameFormat('foo');106 $t->is($w->generateName('foo'), 'foo', '->generateName() returns the name unchanged if the format does not contain %s');107 108 105 $w->setNameFormat(false); 109 106 $t->is($w->generateName('foo'), 'foo', '->generateName() returns the name unchanged if the format is false'); 107 108 try 109 { 110 $w->setNameFormat('foo'); 111 $t->fail('->setNameFormat() throws an InvalidArgumentException if the format does not contain %s'); 112 } 113 catch (InvalidArgumentException $e) 114 { 115 $t->pass('->setNameFormat() throws an InvalidArgumentException if the format does not contain %s'); 116 } 117 118 $w = new sfWidgetFormSchema(array( 119 'author' => new sfWidgetFormSchema(array( 120 'first_name' => new sfWidgetFormInput(), 121 'company' => new sfWidgetFormSchema(array( 122 'name' => new sfWidgetFormInput(), 123 )), 124 )), 125 )); 126 $w->setNameFormat('article[%s]'); 127 $t->is($w['author']->generateName('first_name'), 'article[author][first_name]', '->generateName() returns a HTML name attribute value for a given field name'); 128 $t->is($w['author']['company']->generateName('name'), 'article[author][company][name]', '->generateName() returns a HTML name attribute value for a given field name'); 129 130 // ->getParent() ->setParent() 131 $t->diag('->getParent() ->setParent()'); 132 $author = new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInput())); 133 $company = new sfWidgetFormSchema(array('name' => new sfWidgetFormInput())); 134 $t->is($company->getParent(), null, '->getParent() returns null if there is no parent widget schema'); 135 $company->setParent($author); 136 $t->is($company->getParent(), $author, '->getParent() returns the parent widget schema'); 110 137 111 138 // ->setLabels() ->setLabel() ->getLabels() ->getLabel() ->generateLabelName()