I have a multilanguage Gallery with the following schema (propel, using sfPropel15Plugin)
[code]
# Galleries
  pi_gallery:
    _attributes:
      phpName: Gallery
      isI18N: true
      i18nTable: pi_gallery_i18n
    _propel_behaviors:
      sortable: ~
    id: ~
    article_id:
      type: integer
      foreignTable: pi_article
      foreignReference: id
      required: false
    active:
      type: boolean
      default: true
      required: true
    created_at: ~
    updated_at: ~

  pi_gallery_i18n:
    _attributes:
      phpName: GalleryI18n
    id:
      type: integer
      foreignTable: pi_gallery
      foreignReference: id
      required: true
      primaryKey: true
      onDelete: cascade
    culture:
      isCulture: true
      type: varchar
      size: 7
      required: true
      primaryKey: true
    name:
      type: varchar
      size: 255
      required: false
    description:
      type: longvarchar
      required: false

# Images
  pi_gallery_image:
    _attributes:
      phpName: GalleryImage
      isI18N: true
      i18nTable: pi_gallery_image_i18n
    id: ~
    gallery_id:
      type: integer
      foreignTable: pi_gallery
      foreignReference: id
      required: true
    image:
      type: varchar
      size: 255
      required: true
    created_at: ~
    updated_at: ~

  pi_gallery_image_i18n:
    _attributes:
      phpName: GalleryImageI18n
    id:
      type: integer
      foreignTable: pi_gallery_image
      foreignReference: id
      required: true
      primaryKey: true
      onDelete: cascade
    culture:
      isCulture: true
      type: varchar
      size: 7
      required: true
      primaryKey: true
    description:
      type: varchar
      size: 255
      required: false
[/code]

I'm trying to embed the Image forms in the Gallery using the following:

[code]
# GalleryForm.class

public function configure()
    {
        unset(
            $this['alias'],
            $this['created_at'],
            $this['updated_at']
        );

$this->widgetSchema['article_id']->setOption('renderer_class', 'sfWidgetFormPropelJQueryAutocompleter'); $this->widgetSchema['article_id']->setOption('renderer_options', array(
                'model'     => 'Article',
                'url'       => '/frontend_dev.php/article/ajax'
        ));

        $this->validatorSchema['article_id'] = new sfValidatorPass();

        $this->embedI18n(array('es', 'en', 'de', 'it', 'fr'));

        $this->widgetSchema->setLabel('en','English');
        $this->widgetSchema->setLabel('es','EspaƱol');
        $this->widgetSchema->setLabel('de','Deutsch');
        $this->widgetSchema->setLabel('it','Italiano');
        $this->widgetSchema->setLabel('fr','Francais');

$this->embedRelation('GalleryImage'); // Embeds the Relation between the GalleryImage model and the Gallery Model
    }
[/code]

and in GalleryImageForm.class:
[code]
public function configure()
    {
        unset(
            $this['created_at'],
            $this['updated_at'],
            $this['gallery_id'],
            $this['sortable_rank']
        );

        if ($this->isNew()) unset($this['id']);

        $this->embedI18n(array('es', 'en', 'de', 'it', 'fr'));

        $image = $this->getObject()->getImage();
$template = (!is_null($image) || $image != "") ? '<div>%file%<br />%input%<br />%delete% %delete_label%</div>' : '';

$this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array(
            'label' => 'Imagen',
'file_src' => '/'.sfConfig::get('sf_upload_dir_name').'/images/galleries/thumbs/'.substr($this->getObject()->getImage(),0,-4) . '.jpg',
            'is_image' => true,
            'edit_mode' => !$this->isNew() && $image != "",
            'with_delete' => true,
            'delete_label'=>'Eliminar archivo existente',
            'template' => $template
        ));

        $this->validatorSchema['image_delete'] = new sfValidatorPass();

        $this->validatorSchema['image'] = new sfValidatorFile(array(
            'path' => sfConfig::get('sf_upload_dir').'/images/galleries',
            'required' => false,
            'mime_types' => 'web_images'
        ));
    }
[/code]

This appears to embed the forms as expected ... initially. The GalleryForm appears with Multilanguage Descriptions and the ImageForms embed beneath them. So far so good.

Saving the form however shows that all is not good.

Two records are saved initially, one with just the image and the other with just the i18n fields. The i18n fields also have the id of the second record added so there is no way of relating the image to the i18n fields. Maybe the order of saving the forms is wrong?

Log:
[code]Apr 26 18:31:05 symfony [debug] {sfPropelLogger} time: 0.000 sec | slow: NO | mem: 10.5 MB | mempeak: 10.5 MB | memdelta: 0.0 B | SET NAMES 'utf8' Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | SELECT MAX(pi_gallery.SORTABLE_RANK) FROM `pi_gallery` Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery` (`ID`,`ARTICLE_ID`,`ACTIVE`,`CREATED_AT`,`UPDATED_AT`,`SORTABLE_RANK`) VALUES (NULL,0,1,'2011-04-26 18:31:06','2011-04-26 18:31:06',1) Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_i18n` (`ID`,`CULTURE`,`NAME`,`DESCRIPTION`) VALUES (1,'es','Test','') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_i18n` (`ID`,`CULTURE`,`NAME`,`DESCRIPTION`) VALUES (1,'en','Test','') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_i18n` (`ID`,`CULTURE`,`NAME`,`DESCRIPTION`) VALUES (1,'de','Test','') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_i18n` (`ID`,`CULTURE`,`NAME`,`DESCRIPTION`) VALUES (1,'it','Test','') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_i18n` (`ID`,`CULTURE`,`NAME`,`DESCRIPTION`) VALUES (1,'fr','Test','') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image` (`ID`,`GALLERY_ID`,`CREATED_AT`) VALUES (NULL,1,'2011-04-26 18:31:06') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image_i18n` (`ID`,`CULTURE`,`DESCRIPTION`) VALUES (1,'en','werewr') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image_i18n` (`ID`,`CULTURE`,`DESCRIPTION`) VALUES (1,'de','werwer') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.000 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image_i18n` (`ID`,`CULTURE`,`DESCRIPTION`) VALUES (1,'it','werwer') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.000 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image_i18n` (`ID`,`CULTURE`,`DESCRIPTION`) VALUES (1,'fr','ewrwer') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image_i18n` (`ID`,`CULTURE`,`DESCRIPTION`) VALUES (1,'es','werwer') Apr 26 18:31:06 symfony [debug] {sfPropelLogger} time: 0.001 sec | slow: NO | mem: 14.3 MB | mempeak: 16.0 MB | memdelta: 0.0 B | INSERT INTO `pi_gallery_image` (`ID`,`GALLERY_ID`,`IMAGE`,`CREATED_AT`,`UPDATED_AT`) VALUES (NULL,1,'Image-e15aea77f5.jpg','2011-04-26 18:31:06','2011-04-26 18:31:06')
[/code]

Has anyone successfully got a form to work that embeds I18n in an embedded Relation? Or does anyone have any idea of a workaround? I've read about something about overriding saveEmbeddedForms but I don't even know where to start with that.

Any help appreciated.

--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to