Hi,

I'm having a few weird problems with a Symfony Admin Generator created
module. In short, I have two main Models (Article and Page), and a
many-to-many relationship managed with a through-class (ArticlePage).
ArticlePage also has a boolean property to indicate whether or not the
Article should be featured on the associated Page.

Here's an (abridged) schema.yml:

    page:
        id:
        title:             { type: varchar(255), required: true }

    article:
        id:
        title:               varchar(255)

    article_page:
      article_id:   { type: integer, foreignTable: article,
foreignReference: id }
      page_id:      { type: integer, foreignTable: page,
foreignReference: id }
      featured:     { type: boolean, default: false }

In the backend Article module (created by sfPropelAdminGenerator) I
have an admin_check_list field to handle the many-to-many
relationshop, and a second partial which lists the Pages, next to a
checkbox to indicate whether the Article should be featured on that
Page or not.

I overloaded the updateArticleFromRequest action to include:

protected function updateArticleFromRequest()
{
  $featured = $this->getRequestParameter('feature_on_page');
  foreach($this->article->getArticlePages() as $ap)
  {
    $ap->setFeatured(is_array($featured) && in_array($ap->getPageId(),
$featured));
  }
  return parent::updateArticleFromRequest();
}

When the Article is saved, the ArticlePage choices from the
admin_check_list get saved, but the featured flag doesn't. What's
REALLY weird is that my DB Query Log shows that the items are being
saved with the correct 'featured' flag, but they're then being
deleted, and re-inserted without the featured flag!

Here's the log straight from MySQL:

UPDATE article_page SET FEATURED = 0 WHERE article_page.ID=108
UPDATE article_page SET FEATURED = 0 WHERE article_page.ID=107
UPDATE article_page SET FEATURED = 0 WHERE article_page.ID=106
UPDATE article_page SET FEATURED = 1 WHERE article_page.ID=105
UPDATE article_page SET FEATURED = 1 WHERE article_page.ID=104
UPDATE article_page SET FEATURED = 1 WHERE article_page.ID=103
DELETE FROM article_page WHERE article_page.ARTICLE_ID=221
INSERT INTO article_page (ARTICLE_ID,PAGE_ID) VALUES (221,2)
INSERT INTO article_page (ARTICLE_ID,PAGE_ID) VALUES (221,34)
INSERT INTO article_page (ARTICLE_ID,PAGE_ID) VALUES (221,65)
INSERT INTO article_page (ARTICLE_ID,PAGE_ID) VALUES (221,75)
INSERT INTO article_page (ARTICLE_ID,PAGE_ID) VALUES (221,80)
INSERT INTO article_page (ARTICLE_ID,PAGE_ID) VALUES (221,91)

I don't geddit. Any idea where I should start looking? I haven't
overloaded any of the Article or ArticlePage's (do)Save methods - bit
weird, huh?

Ben

--~--~---------~--~----~------------~-------~--~----~
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