2009-12-01 63 views
2

我無法在國際化字段上同時使用i18n和tinyMCE小部件。 如果我把兩者都放在一起,我會爲我的所有物品的領域設置國際化的領域,但是對他們來說沒有小型的MCE。我將擁有儘可能多的tinyMCE字段,但是它們不會對應任何語言,它們將在開頭或結尾。 它完美地工作之前,我國際化的對象Symfony:如何在後端使用帶有i18n格式的小部件(教條)

下面是代碼的示例:

//配置/教義/的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 /形式/教義/ 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); 

} 

,所以我想,當我使用$這 - > widgetSchema [「前奏」],在「介紹」的名稱不符合所有的國際化「前奏」領域。我嘗試了'en_intro'和'intro_en',但它沒有任何魔法。 所以,也許你可以幫助我?

回答

1

所以,我發現如何做到這一點,我想這可能感興趣的人:

而不是

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

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

與所有的語言。

1

也可以使用:

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

移動的國際化標籤和字段之前介紹領域。

相關問題