2016-05-17 88 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"