Symfony : 백엔드에서 i18n 양식을 사용하여 위젯을 사용하는 방법 (교리)
-
22-07-2019 - |
문제
국제화 된 필드에 I18N과 Tinymce 위젯을 모두 가질 수 없습니다. 두 가지를 모두 넣으면 모든 물체의 필드에 대한 국제화 된 필드가 있지만 Tinymce는 없습니다. 나는 내가 선언 한 것만 큼 많은 tinymce 필드를 가질 것이지만, Thew는 어떤 언어에도 해당되지 않으며, 처음이나 끝에있을 것입니다. 물체를 국제화하기 전에 완벽하게 작동했습니다
코드의 예는 다음과 같습니다.
// 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);
}
그래서 $ this-> widgetschema [ 'intro']를 사용할 때 "소개"이름이 모든 i18n "Intro"필드에 해당하지는 않습니다. 나는 'en_intro'와 'intro_en'을 모두 시도했지만 마법은 아닙니다. 그래서 당신은 나를 도울 수 있을까요?
해결책
그래서 나는 이것을하는 방법을 찾았고 누군가에게 관심을 가질 것이라고 생각했습니다.
대신에
$this->widgetSchema['intro'] = ...
놓다
$this->widgetSchema['en']['intro'] = ...
모든 언어로.
다른 팁
또한 사용할 수 있습니다.
$this->widgetSchema->moveField('en',sfWidgetFormSchema::BEFORE,'intro');
I18N 레이블과 필드를 인트로 필드로 이동하십시오.
제휴하지 않습니다 StackOverflow