} public function getStylesheets() { return array('/path/to/a/file.css' => 'all'); } } $w->setOption('renderer_class', 'MyWidget'); $t->is(get_class($w->getRenderer()), 'MyWidget', '->getRenderer() uses the renderer_class as the widget class if provided'); $w->setOption('renderer_class', null); $w->setOption('renderer', new MyWidget(array('choices' => array()))); $t->is(get_class($w->getRenderer()), 'MyWidget', '->getRenderer() uses the renderer as the widget if provided'); // ->render() $t->diag('->render()'); $w = new sfWidgetFormChoice(array('choices' => array('foo' => 'bar'))); $t->like($w->render('foo'), '/<select name="foo" id="foo">/', '->render() renders a select tag by default'); $w->setIdFormat('barID_%s'); $t->like($w->render('foo'), '/<select name="foo" id="barID_foo">/', '->render() uses the id format specified'); $w->setIdFormat('%s'); $w->setOption('multiple', true); $t->like($w->render('foo'), '/<select name="foo\\[\\]" multiple="multiple" id="foo">/', '->render() adds a multiple attribute for multiple selects'); $w->setOption('expanded', true); $t->like($w->render('foo'), '/<ul class="checkbox_list">/', '->render() uses a checkbox list when expanded and multiple are true'); $w->setOption('multiple', false); $t->like($w->render('foo'), '/<ul class="radio_list">/', '->render() uses a checkbox list when expanded is true and multiple is false'); // choices are translated $t->diag('choices are translated'); $ws = new sfWidgetFormSchema(); $ws->addFormFormatter('stub', new FormFormatterStub()); $ws->setFormFormatterName('stub'); $w = new sfWidgetFormChoice(array('choices' => array('foo' => 'bar', 'foobar' => 'foo'))); $w->setParent($ws);