당신은 form.post_configure 이벤트를 할 듣고해야합니다. 나는 일반적으로 다음과 같은 내 프로젝트 구성 수업이 있습니다
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->dispatcher->connect('form.post_configure', array($this, 'listenToFormPostConfigure'));
}
/**
* Listens to the command.post_command event.
*
* @param sfEvent An sfEvent instance
* @static
*/
static function listenToFormPostConfigure(sfEvent $event)
{
sfProjectConfiguration::getActive()->loadHelpers('I18N');
$form = $event->getSubject();
$widgetSchema = $form->getWidgetSchema();
foreach ($form->getValidatorSchema()->getFields() as $fieldName => $validator)
{
if (isset($widgetSchema[$fieldName]))
{
$label = $widgetSchema[$fieldName]->getLabel() ? $widgetSchema[$fieldName]->getLabel()
: sfInflector::humanize($fieldName);
$label = __($label);
$asterisk = $validator->getOption('required') ? ' *' : null;
$widgetSchema[$fieldName]->setLabel($label . $asterisk . ' :');
}
}
}
}
이 필요한 라벨에 별표를 추가하고 또한 라벨을 변환합니다. 희망은 당신에게도 유용 할거야.