views:

857

answers:

3

Hi everybody.

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

Here is an example of code :

// config/doctrine/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/doctrine/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 ?

A: 

So i found how to do this and i thought it might interest somebody :

Instead of

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

Put

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

with all the languages.

Julien
+1  A: 

also you can use :

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

move the i18n label and field to before intro field.

andromeda
A: 

Awesome.. thanks for that hint.. should also work fine taking the language codes from your database and initialize all widgetSchema with an foreach loop..

great.. thanks :)

chris