我尝试向自定义 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())。
有人能帮我解释一下吗?
非常感谢。