Symfony: backend i18n formları ile widget nasıl kullanılır (doktrin)

2 Cevap php

I can not manage to have both i18n and tinyMCE widgets on internationalised fields. If i put both, i will have internationalised fields for all my objects' fields, but no tinyMCE for them. I will have as much tinyMCE fields as i declared, but thew will not correspond to any language, they will be at the beginning or at the end. It worked perfectly before i internationalized the objects

İşte kod bir örnektir:

/ / Config / doktrin / schema.yml

MyObject:
  actAs:
    I18n:
      fields: [title, subtitle, intro, text]
  columns:
    title: {type: string(500)}
    subtitle: {type: string(500)}
    intro: {type: string(4000)}
    text: {type: string(16000)}

/ / Lib / form / doktrin / MyObject.class.php

public function configure()
{

$this->embedI18n(array('en', 'fr', 'es'));
$this->widgetSchema->setLabel('fr', 'Français');
$this->widgetSchema->setLabel('en', 'Anglais');
$this->widgetSchema->setLabel('es', 'Español');

$this->widgetSchema['intro'] =  new sfWidgetFormTextareaTinyMCE(
  array(
    'width'=>600,
    'height'=>100,
    'config'=>'theme_advanced_disable: "anchor,image,cleanup,help"',
    'theme'   =>  sfConfig::get('app_tinymce_theme','simple'),
  ),
  array(
    'class'   =>  'tiny_mce'
  )
);

$this->widgetSchema['text'] =  new sfWidgetFormTextareaTinyMCE(
  array(
    'width'=>600,
    'height'=>100,
    'config'=>'theme_advanced_disable: "anchor,image,cleanup,help"',
    'theme'   =>  sfConfig::get('app_tinymce_theme','simple'),
  ),
  array(
    'class'   =>  'tiny_mce'
  )
);

$js_path = sfConfig::get('sf_rich_text_js_dir') ? '/'.sfConfig::get('sf_rich_text_js_dir').'/tiny_mce.js' : '/sf/tinymce/js/tiny_mce.js';
sfContext::getInstance()->getResponse()->addJavascript($js_path);

}

So i guess when i use $this->widgetSchema['intro'], the "intro" name does not correspond to all the i18n "intro" fields. I tried both 'en_intro' and 'intro_en', but it doesn't do any magic. So maybe you could help me ?

2 Cevap

Yani ben bunu nasıl bulundu ve ben bunu birilerine ilgi olabilir düşündüm:

Yerine

 $this->widgetSchema['intro'] = ...

Koymak

$this->widgetSchema['en']['intro'] = ...

tüm dilleri ile.

da kullanabilirsiniz:

$this->widgetSchema->moveField('en',sfWidgetFormSchema::BEFORE,'intro');

intro alanına önce için i18n etiket ve alanını taşıyın.