Monday, January 25, 2010

Deep nested data in forms

I have some connected models: e.g. (made up example):

Post->Comment->Author->Address

My controller's index action creates an array using a model find
function using the containable behaviour - let's call the output
$postSummary.

I have a form that displays data from across the $postSummary array:
e.g.;

Stuff about the Post
The comments belonging the Post
Some info about the Author of the Post
The Address of the Author.

I want to create a form on this page that allows me to edit the
Author's Address details on this page. I can see the data in the
array:

$postSummary[0][Comment][0][Author][Address][..fields...]

...and I can display using them a simple echo statement.

My question is:

How can I create a form and display that same information ready for
edit?

I have tried all sorts of variations of form options and input names,
with no luck:

Is it because I don't have an array called $this->data? If so, how do
I access the stuff and goodness inside it and post it back to my
controller function?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: