On Jan 19, 2008 1:01 PM, R. Rajesh Jeba Anbiah
<[EMAIL PROTECTED]> wrote:
> I'm not sure, if you have understand my question. RoR based
> frameworks allow easy creation/use of form when DB table is created.
> But, I'm looking for a solution to create forms dynamically--something
> as in LimeSurvey.
I *think* I may have run into what you're talking about here. I'm
building a section of a web site for voting on things (the simulation
baseball league I am in has a vote during the off-season for changing
league rules and rules for the game we use), and there can be any
number of items on the ballot.
So, while googling around looking for some help on this I found that
you can use the following notation to create multiple instances of the
same field:
$form->input("{$x}.Model.field")
In my case, I loop through each item in the ballot and present a radio
button to allow me to vote on it.
<?php
$x = 1;
$answerOptions = array('Yes' => 1, 'No' => 0, 'Abstain' => 2);
foreach ($ballotItems as $ballotItem) {
echo $form->radio("{$x}.Vote.answer", $answerOptions)
$x++;
}
?>
Then, when you submit the form to be processed, you should see
something like this in $this->data
$this->data[1]['Vote']['answer'] = ...
$this->data[2]['Vote']['answer'] = ...
Hope that helps.
--
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---