我收到以下错误
The option "label " does not exist. Known options are: "always_empty", "attr", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_protection", "csrf_provider", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "mapped", "max_length", "pattern", "post_max_size_message", "property_path", "read_only", "required", "translation_domain", "trim", "validation_constraint", "validation_groups", "virtual"
虽然在documentation中他们说它有label
选项。
我的代码如下:
namespace ....
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class AddNew extends AbstractType
{
private $languages;
public function __construct($languages){
$this->languages = $languages;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
echo "<pre>";//debugging
print_r($this->languages);//debugging
$builder->add('Key');
foreach ($this->languages as $key => $language){
$builder->add('translation'.$key, 'password' , array('label '=>$language['description'].' translation'));
}
}
some other irrelevant stuff ......
}
答案 0 :(得分:3)
看起来你有一个额外的空格:"label "
与"label"
不同。