Hey everyone,
So, I've googled everything in regards to adding multiple records in a
single form and I have not had any beginners luck.
My cakephp project consist of creating an online business survey for
future clients who need a web site developed. The survey has three key
tables related to my problem,
- Responses
- Clients
- Questions
The setup:
Note: CakePHP v1.2.0.7962 and MySQL
In my view, I am passed an array of questions from the Question model
and I display them using a loop. Additionally, I am creating text
areas which are assigned to the 'Response.response' field name from
Response model.
How do I go about saving the data so that each question ID, response,
and the associated client ID are inserted into the Response table?
//create survey form
echo $form->create('Response',array('action'=>'add')) . "\n";
echo $form->input('Response.client_id',array('type'=>'hidden', 'value'
=> $client_id));
?>
<ul>
<?
$question_number = 1;
foreach ($Questions as $question):
// '.$question['Question']['question_id'].'.
?>
<li>
<b><?php echo $question_number++ . ". " .
$question['Question']
['question']; ?></b>
<br />
<? echo $form->textArea('Response.response',
array('label'=>$question['Question']['question_id'])); ?>
<br />
<? echo $form->input('Response.question_id',
array
('type'=>'hidden','value'=>$question['Question']['question_id'])); ?>
<br />
</li>
<?
endforeach;
echo $form->end('Continue');
?>
</ul>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---