Question

I have a weird problem with my i18n doctrine schema and i.a. the admin generator.

(Please look at the edit part below first)

The schema looks like:

CargoSize:
  connection: doctrine
  actAs:
    Timestampable:      ~
    I18n:
      fields:                   [name, linkname, seoname, description]
  tableName: com_cargo_size
  columns:
    id:                                     { type: integer(11), notnull: true, unsigned: true, primary: true, autoincrement: true }
    name:                                   { type: string(50),  notnull: true }
    linkname:                               { type: string(100), notnull: true }
    seoname:                                { type: string(100), notnull: true }
    description:                            { type: string(255), notnull: true }

The first problem I have with sfForms:

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false), array('style' => 'list-style-type: none; display: inline;'))

This generates a radio butten set with the correct IDs, but empty name values. Even when I try to get the name value by directly selecting a CargoSize object by ID and LANG, getName() always returns an empty string (the DB is filled correctly with suitable data).

So is somethng worng with the schema definition??

The second problem appears with the admin-generator:

php symfony doc:generate-admin --module=cargo_size admin CargoSize

The generator.yml looks like:

generator:
  class: sfDoctrineGenerator
  param:
    model_class:           CargoSize
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          cargo_size
    with_doctrine_route:   true
    actions_base_class:    sfActions

    config:
      actions: ~
      fields:  ~
      list:
        display: [name, lang]
      filter:  ~
      form:    ~
      edit:
        display: [name]
      new:     ~

The funny thing is, that the list view shows me the i18n name. But in edit view I always get the error "widget 'name' does not exist".

Do you guys have any idea why this happens? I would be very thankful for your help.

EDIT:

I think the problem sits deeper, because this simple peace of code does note work:

First the datasets for the examples:

cargo_size
id  created_at              updated_at
1   2010-04-22 21:37:44     2010-04-22 21:37:44

cargo_size_translation
id      name    linkname    seoname     description     lang
1       klein   klein       klein       klein           de
1       small   small       small       small           en

$c = Doctrine::getTable('CargoSize')->findOneBy('id', 1); 
echo $c;  // (toString exists)

// Output: Catchable fatal error: Method CargoSize::__toString() 
// must return a string value in 
// /var/www/.../apps/frontend/modules/start/templates/indexSuccess.php on line 1

echo $c->getName();
// Output: nothing

Does somebody has any idea? I'm really deperated :(

Was it helpful?

Solution 2

I found the bug. For some reason the culture was set to "de_DE" instead of just "de". With this setting the i18n behavior stuff didn't work!

OTHER TIPS

First problem :

The "names values" displayed are taken from the __toString() method result. You could add the "method" options, like this :

new sfWidgetFormDoctrineChoice(array('model' => 'CargoSize', 'expanded' => true, 'multiple' => false, 'method' => 'getName'), array('style' => 'list-style-type: none; display: inline;'))

Second problem :

Your form must embed the i18n form. To do this, put this in the configure method :

$this->embedI18n($cultures);

where $cultures is an array of your cultures codes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top