0

In my symfony 1.4 project I want to change label of form text. I can do that by following code:

$this->setWidget('first_name', new sfWidgetFormInputText(array('label' => 'First Name')));

But I can't do that if I add 'label' in the following code, as probably sfValidatorString doesn't accept 'label'.

$this->setValidator('banner_id', new sfValidatorString(array('min_length' => 9)));

How can I solve this?

4

4 回答 4

0

您还可以使用更改所有字段标签

$this->widgetSchema->setLabels(array(
      "widget_name_first" => "my widget label",
      "widget_name_second" => "my widget label",
));
于 2013-08-13T23:34:23.287 回答
0

尝试:

$this->widgetSchema['feildname']->setLabel('Label Text');
于 2013-08-04T10:12:59.487 回答
0

您还可以从 generator.yml 文件配置您的标签。例如:

config:
  actions: ~
  fields:
    date:
      label: Date of birth
      date_format: dd/MM/yy
    address: 
      label: Work address
于 2020-06-03T12:29:49.310 回答
0

试试这个:

$this->getWidgetSchema()->setLabel('fieldName', 'Custom label');

或者:

$this->getWidget('fieldName')->setOption('label', 'Custom label');
于 2019-06-04T14:03:23.743 回答