Tuesday, December 2, 2008

Re: correct way to create multiple text forms in a table

Could you query again, but without all the table display stuff? You have 4 text boxes in a view and ... what?

What's the model name, and what models is it associated to (and how)?

Or is it 4 separate forms? 5?

On Wed, Dec 3, 2008 at 12:27 AM, Todd M <toddmetcalf@gmail.com> wrote:

I'm creating a table where the top header row and left column are
text, but everything in the middle will be a text box. So if the table
was 5x5, there would be a 4x4 matrix of text boxes.

Each of these text inputs will represent a different entry to be saved
at the same model. My plan is to have one submit and the controller
will will call a model->saveall function. However of the text box
forms has a id associated to the top row and leftmost column. In other
words the form is saving to a model that has belongsTo association
with the top row and left.

Is there something that I'm missing on how to have this association
linked with each $form->input.

(Note:example has top left cell blank intentionally)
<tr>
 <td>  </td>
 <td>x1</td>
 <td>x2</td>
</tr>
<tr>
 <td>y1</td>
 <td>text form x1/y1 for modelz</td>
 <td>text form x2/y1 for modelz</td>
</tr>
<tr>
 <td>y2</td>
 <td>text form x1/y2 for modelz</td>
 <td>text form x2/y2 for modelz</td>
</tr>

So the submit would save four entries into the model.

My question is how to use the form helper? And/or is there other best
practices out there.

The only solution that I can come up with is to not use the
'Modelname.fieldname' in the naming convention and have the controller
parse the name into cake naming convention before saving.



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