1
votes

Example from my schema.yml:

Service:
  actAs:
    I18n:
      fields: [title]
    tableName: services
    columns:
      id: { type: integer(3), primary: true, autoincrement: true }
      title: { type: string(255) }

DailyHoroscope:
   actAs:
     Timestampable: ~
     I18n:
       fields: [ description ]
   tableName: daily_horoscopes
   inheritance:
     type: concrete
     extends: Service
   columns:
     description: { type: text }
     date: { type: date }
     starsign_id: { type: integer(1), notnull: true }
   relations:
     Starsign:
       type: one
       class: Starsign
       local: starsign_id
       foreign: id

In the result only title is internationalized. Also in database only title is internationalized.

I tryed to google the issue, but without any results.

In database, in table daily_horoscopes_translations I have only title for translation. In form only title field is internationalized, but description is only one.

In BaseDailyHoroscopeTranslationFormFilter.class.php:

public function getFields()
{
  return array(
  'id'    => 'Number',
  'title' => 'Text',
  'lang'  => 'Text',
  );
}

but if you add 'description' - it won't work, because database is generated in wrong way.

1
Can you please expand more on what the problem is? - d.syph.3r

1 Answers

2
votes

Describe i18n fields in child table, not in parent:

    Service:
#      actAs:
#        I18n:
#          fields: [title]
        tableName: services
        columns:
          id: { type: integer(3), primary: true, autoincrement: true }
          title: { type: string(255) }

    DailyHoroscope:
       actAs:
         Timestampable: ~
         I18n:
           fields: [ description, title ]
       tableName: daily_horoscopes
       inheritance:
         type: concrete
         extends: Service
       columns:
         description: { type: text }
         date: { type: date }
         starsign_id: { type: integer(1), notnull: true }
       relations:
         Starsign:
           type: one
           class: Starsign
           local: starsign_id
           foreign: id

Then unset inherited fields (in our case it's the 'title') field in your form and finally embed i18n form objects:

unset($this['title']);
$this->embedI18n(array('en','fr','ru'));