I have a problem with internalization of doctrine objects' forms in administration. Forms worked perfectly fine, but then I added support for multiple languages.
Schema looks like this:
content:
actAs:
Timestampable: ~
I18n:
fields: [title, content]
columns:
parent: { type: integer }
title: { type: string(255), notnull: true, unique: true }
slug: { type: string(255), notnull: true, unique: true }
content: { type: string }
link: { type: string(255) }
ord: { type: integer }
type: { type: integer, default: 0 }
relations:
content: { onDelete: CASCADE, local: parent, foreign: id }
indexes:
parent: { fields: [parent] }
slug: { fields: [slug] }
type: { fields: [type] }
Admin generator:
generator:
class: sfDoctrineGenerator
param:
model_class: content
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: content
with_doctrine_route: true
actions_base_class: sfActions
config:
actions: ~
fields:
title: { is_real: false }
typeFull: { label: Type }
list:
display: [=title, typeFull]
sort: ord
max_per_page: 100
filter:
class: false
form:
class: adminContentForm
edit: ~
new: ~
And finally a form:
class adminContentForm extends BasecontentForm
{
public function configure()
{
unset($this['slug'], $this['ord'], $this['created_at'], $this['updated_at']);
$this->embedI18n(array('de', 'fr'));
$this->widgetSchema->setLabel('de', 'Deutsch');
$this->widgetSchema->setLabel('fr', 'French');
}
}
I didn't change action class.
Everything works just fine when I want to create a new entry. But a strange problem occurs when I want to update an existing entry: it saves only fields in embedded i18n forms (title, content) and fields from main form stay untouched (parent, link, type).
If I delete embedding from form, it saves parent, linky and type properly. If I add embedding back, it saves only title and content.
Have you ever encountered similar problem? I'm using Symfony 1.4.17.
EDIT:
If I add this for debugging to processForm() method in actions.class.php:
var_dump($form->getValue('link'));
$content = $form->save();
var_dump($content->getLink());
exit();
... I see that a value in a field link was properly sent, but after saving a form the value isn't saved. $form->getValue('link') returns a proper value, but $content->getLink() returns an empty string.