Prezent / doctrine-translatable

Translatable behaviour extension for Doctrine2
MIT License
26 stars 17 forks source link

Having non-translatable field #2

Closed ghost closed 10 years ago

ghost commented 10 years ago

Is it possible to have a field which would be the same for all locales (= non-translatable)? I have an entity where only fields name and description should be translated, but price should be the same for all. However, it doesn't seem that leaving it in the original entity class would work. I tried putting in setter and getter for the price field in translation entity, but it still checks for existing property. Btw, I'm using a2lixtranslations and the form code to display the fields:

->add('translations', 'a2lix_translations', array(
    'label'  => false,
    'fields' => array(
        'name' => array(),
        'price' => array(
            'locale_options' => array(
            'lt' => array(
                'display' => false,
                ),
            ),
        ),
        'description' => array(),
    ),
))
sandermarechal commented 10 years ago

You can just leave that field in the original entity and add it as a regular field to the form. Example:

$formBuilder
    ->add('translations', 'a2lix_translations', array(
        'fields' => array(
            'name' => array(),
            'description' => array(),
        ),
        // ... label, etc.
    )
    ->add('price', 'number', array(
        // ... label, etc.
    )
;
ghost commented 10 years ago

That's right.. Thanks.

sandermarechal commented 10 years ago

You're welcome. Let me know if you run into any other issues.