Ok ... don't do what I did - if you're passing data to an XML view,
MAKE SURE it's in the form of an associative array.

He'res the break down of my problem. In my controller, I did $result =
$this->Post->Tag->Find. That of course gave me a $result that looked
something like:

Array (

  ['Tag']
    [0] => Array ( ...

  [Post]
    [0] => Array( ...
)

but I only needed the tag stuff in my view so I did $this->set('tag',
$result['Tag']). The problem was the data passed to the view wasn't in
a associative array any longer, so the XMLHelper couldn't determine
what type of  XML element it should create.

With a little digging thru XMLHelper, XML, and Set I found that, since
the find() recursion was set high enough, Set:map() ended thinking the
PostTag Tag attribute was the XML element type.  In my mind this
should have been an error. I certainly caused the issue, but I think
map() should understand it's not dealing with an associative array
throw an warning/error vs. simply recursing down until it finds a
distant associative array.


FYI:  If you tighten up the recursion so map() never finds an
associative array, your XML element will simply be created as
<stdClass />




On Sep 10, 10:30 am, GTM <[EMAIL PROTECTED]> wrote:
> Has anyone run across a situation with XML HABTM query results where
> the XML differs from the std results?    I have a Post, Tags
> scenerio.  I'm using a RequestHandler setup so /post/index.xml
> returns:
>
> <post id="1" />
> <post id="2" />
> ...
>
> That's good. But when I do a $this->Post->Tags->Find I get:
>
> <tag id="1">
>     <post_tag id="1" />
>     <post_tag id="2" />
> </tag>
> <tag id="2">
>  ...
>
> I didn't expect the join table to show up.  I would expected:
>
> <tag id="1">
>     <post id="1" />
>     <post id="2" />
>   ...
>
> Seems like the regular array results don't include the join table.  Am
> i mistaken or perhaps missing something here?
>
> -GTM
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to