2013-02-20 72 views
2

虽然在documentation他们说,它有一个label选项我收到以下错误选项“标签”不存在

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" 

我的代码如下:

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 ...... 
} 

回答

3

看起来你在那里有一个额外的空间:"label "是不一样的"label"

+0

6小时没事吧?! – 2013-02-20 07:16:58

+0

我会尽我所能接受答案,感谢您的帮助..我应该已经注意到了! – 2013-02-20 07:17:16

+1

@codeiz C'est la vie,不客气。 – 2013-02-20 07:22:19