2016-05-17 87 views
0

我在My Symfony项目中有一个实体,名为“品牌”,可为空,但我希望它对于客户端是必需的,但它不起作用。而她不知道是什么问题A2lix翻译表格要求真实吗?

实体:

/** 
* @var string 
* 
* @ORM\Column(name="brand", type="string", length=255, nullable=false) 
*/ 
private $brand; 

形式:

->add('translations', 'a2lix_translations', array(
       'fields' => array(
        'brand' => array(
         'field_type' => TextType::class, 
         'required' => true 
        ), 
       ) 
      ) 
     )` 

我也试过,但仍然无需出现在面前:

->add('translations', 'a2lix_translations', array(
       'fields' => array(
        'brand' => array(
         'field_type' => TextType::class, 
         'locale_options' => array(   
           'en' => array(
           'required' => true 
          ), 
           'fr' => array(
           'required' => true 
          ) 
         ) 
        ), 
       ) 
      ) 
     )` 

结果在浏览器这两种情况是:

<input type="text" id="video_form_translations_en_brand" name="video_form[translations][en][brand]" maxlength="255" class="form-control"> 

回答

0

我只是纠正了问题设置两种语言在我config.yml所需的语言环境。现在,我所需的真实字段具有必需的属性,而非必填字段仍然不是必需的。

# A2lix Configuration 
a2lix_translation_form: 
    locale_provider: default 
    locales: "%languages%"   # locales available for the forms 
    default_locale: "%locale%"  # default locale 
    required_locales: [en, fr]   # requireds locales (not all fields will be required - only the ones with required true) 
    manager_registry: doctrine 
    templating: "A2lixTranslationFormBundle::default.html.twig"