【发布时间】:2011-03-08 21:11:32
【问题描述】:
我尝试在我的自定义 sfForm 中为标签添加一些 css 属性,但我无法实现。
在我的自定义类 myForm extends sfForm 中,我动态创建所有文本字段:
public function configure()
{
$widgetFixtures = array();
foreach ($fixtures as $fixture) {
$widgetFixtures[$fixture->getId()] = new sfWidgetFormInputText(
array('label' => $fixture->getTeamNameDom()),
// I would like to add something like: array('class' => $fixture->getCSS()),
array('value' => $fixture->getScore1(), 'readonly' => 'readonly')
);
}
$this->setWidgets($widgetFixtures);
}
我尝试使用setFormFormatterName 格式化渲染,但没有成功。
注意:我不能在模板中使用renderLabel($value, $attributes = array()),因为我从数据库中获取了 CSS 类(如您所见,我必须使用:$fixture->getCSS())。
有人能帮我解释一下吗?
非常感谢。
【问题讨论】:
标签: css forms symfony1 label symfony-forms