i18n form fields in admin generator

25 views
Skip to first unread message

Dmitry Kermanov

unread,
May 15, 2014, 4:24:16 PM5/15/14
to diem-...@googlegroups.com
I have multilingual website with two cultures: en, ru
I have module Property, that has Property table with i18n fields related to it. Here is the schema.yml:
Property:
  actAs:
    I18n:
      fields:                     [ name, description ]
  columns:
    name:                       { type: string(255) }
    description:               { type: clob }
 
And modules.yml:

  "Content":

    property:
      model:                      Property
      name:                       "Property"
      admin:                      true
 
Admin module works fine too. But in Property add/edit admin form has only current's culture input fields. For example, if the current culture is 'en' it has only english inputs for fields: name and description, and doesn't have russian inputs. And for "ru' the form have only russian inputs of these fields.
What I want is to have both english and russian inputs in admin form for each culture. May be there are some special settings in admin generator generator.yml file for this? Or what is the easiest way to do this?

Jarek Rencz

unread,
May 15, 2014, 4:55:54 PM5/15/14
to diem-...@googlegroups.com
The thing you're trying to achieve is not what Diem default admin generator is designed to do AFAIK.
You can though write your own view/template for this model form (thus opt out of using yml configured generated views) and a custom controller to handle save action.
It's not the easiest way (It's not that hard either) and it's quite imperative, but I don't know if any other, much easier exists.

If you're done with configuring you can grab generated partial from cache folder, modify it (by adding locale fields). Then you'd have to extend the controller and write your own save logic. It won't take long this way. All you have to remember - this particular view won't be auto generated anymore. You would be able to see generated view again once you remove (or rename) your declared partial - this may be a way to make changes.

But if your system is large and you have to provide this functionality in may places you should consider extending the generator itself in my opinion. It will take longer but then you will benefit from not loosing the declarative configuration.

TheCelavi

unread,
May 16, 2014, 5:52:29 AM5/16/14
to diem-...@googlegroups.com
"The thing you're trying to achieve is not what Diem default admin generator is designed to do AFAIK." -> absolutely true! 
Reply all
Reply to author
Forward
0 new messages