Changeset 8756
- Timestamp:
- 05/03/08 22:01:36 (6 months ago)
- Files:
-
- branches/1.1/lib/widget/sfWidgetFormSchema.class.php (modified) (1 diff)
- branches/1.1/test/unit/form/sfFormTest.php (modified) (2 diffs)
- branches/1.1/test/unit/widget/sfWidgetFormSchemaTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/widget/sfWidgetFormSchema.class.php
r8485 r8756 333 333 $widget = $this[$name]; 334 334 $value = isset($values[$name]) ? $values[$name] : null; 335 $error = isset($errors[$name]) ? $errors[$name] : array(); 336 $widgetAttributes = isset($attributes[$name]) ? $attributes[$name] : array(); 335 337 336 338 if ($widget instanceof sfWidgetForm && $widget->isHidden()) 337 339 { 338 $hiddenRows[] = $widget->render($this->generateName($name), $value );340 $hiddenRows[] = $widget->render($this->generateName($name), $value, $widgetAttributes); 339 341 } 340 342 else 341 343 { 342 $error = isset($errors[$name]) ? $errors[$name] : array(); 343 $field = $this->renderField($name, $value, array(), $error); 344 $field = $this->renderField($name, $value, $widgetAttributes, $error); 344 345 345 346 // don't add a label tag and errors if we embed a form schema branches/1.1/test/unit/form/sfFormTest.php
r7154 r8756 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(8 5, new lime_output_color());13 $t = new lime_test(87, new lime_output_color()); 14 14 15 15 class FormTest extends sfForm … … 247 247 $t->is($f->renderGlobalErrors(), $output, '->renderGlobalErrors() renders global errors as an HTML list'); 248 248 249 // ->render() 250 $t->diag('->render()'); 251 $f = new FormTest(); 252 $f->setValidators(array( 253 'id' => new sfValidatorInteger(), 254 'first_name' => new sfValidatorString(array('min_length' => 2)), 255 'last_name' => new sfValidatorString(array('min_length' => 2)), 256 )); 257 $f->setWidgets(array( 258 'id' => new sfWidgetFormInputHidden(), 259 'first_name' => new sfWidgetFormInput(), 260 'last_name' => new sfWidgetFormInput(), 261 )); 262 $f->bind(array( 263 'id' => '1', 264 'first_name' => 'Fabien', 265 'last_name' => 'Potencier', 266 )); 267 $output = <<<EOF 268 <tr> 269 <th><label for="first_name">First name</label></th> 270 <td><input type="text" name="first_name" value="Fabien" id="first_name" /></td> 271 </tr> 272 <tr> 273 <th><label for="last_name">Last name</label></th> 274 <td><input type="text" name="last_name" value="Potencier" id="last_name" /><input type="hidden" name="id" value="1" id="id" /></td> 275 </tr> 276 277 EOF; 278 $t->is($f->__toString(), $output, '->__toString() renders the form as HTML'); 279 $output = <<<EOF 280 <tr> 281 <th><label for="first_name">First name</label></th> 282 <td><input type="text" name="first_name" value="Fabien" class="foo" id="first_name" /></td> 283 </tr> 284 <tr> 285 <th><label for="last_name">Last name</label></th> 286 <td><input type="text" name="last_name" value="Potencier" id="last_name" /><input type="hidden" name="id" value="1" id="id" /></td> 287 </tr> 288 289 EOF; 290 $t->is($f->render(array('first_name' => array('class' => 'foo'))), $output, '->render() renders the form as HTML'); 291 249 292 // ->embedForm() 250 293 $t->diag('->embedForm()'); branches/1.1/test/unit/widget/sfWidgetFormSchemaTest.php
r8408 r8756 309 309 <li>Too short</li> 310 310 </ul> 311 <input class="foo 1" type="text" name="article[first_name]" id="id_article_first_name" /></td>311 <input class="foo" type="text" name="article[first_name]" value="Fabien" id="id_article_first_name" /></td> 312 312 </tr> 313 313 <tr> 314 314 <th><label style="padding: 5px" for="id_article_last_name">Last name</label></th> 315 <td><input type="text" name="article[last_name]" id="id_article_last_name" /><input type="hidden" name="article[id]" id="article_id" /></td>315 <td><input type="text" name="article[last_name]" value="Potencier" class="bar" id="id_article_last_name" /><input type="hidden" name="article[id]" id="article_id" /></td> 316 316 </tr> 317 317 318 318 EOF; 319 $rendered = $w->render(null, array(' w1' => 'Fabien', 'w2' => 'Potencier'), array(), array('first_name' => 'Too short', 'Global error message', 'id' => 'Required'));319 $rendered = $w->render(null, array('first_name' => 'Fabien', 'last_name' => 'Potencier'), array('first_name' => array('class' => 'foo'), 'last_name' => array('class' => 'bar')), array('first_name' => 'Too short', 'Global error message', 'id' => 'Required')); 320 320 $t->is($rendered, $expected, '->render() renders a schema to HTML'); 321 321