Hi,
I have a situation like this: several practices are read from the db
and presented in a table (there's a form around the table) with a
checkbox near each one of them; simply, I need to check or uncheck the
practices I need and the when I press submit I want the application to
save them into a db with this format:
1) their ID
2) applicable (it's an ENUM '1' or '0')
I can register them correctly...but only one! Since I have 12
practices...why it doesn't save them all? I put here the code:
- controller
function setup($id=null)
{
// Let's check if you're an administrator
if($this->Session->read('userlevelid') == 0)
{
// Let's switch through the different models
supported
if (empty($this->params['data']))
{
$this->helpers = array('Javascript',
'Ajax');
$assessment =
$this->Assessment->findById($this->Session->read('assessment'));
switch($id)
{
case 1:
// It's the CMMI V1.1 STAGED
SE-SW-IPPD-SS
$this->set('model',
$this->Assessment->RefModel->AppraisalModel->findAll('AppraisalModel.ml
<= ' . $assessment['Objective']['objective']));
break;
}
}
else
{
//$assessment =
$this->params['data']['Assessment'];
//unset
($this->params['data']['Assessment']);
if
($this->Assessment->AssessmentModel->save($this->params['data']['AssessmentModel']))
{
/*$id =
$this->Assessment->Sponsor->getLastInsertId ();
$assessment['sponsor_id'] = $id;
$this->Assessment->save(array
('Assessment' => $assessment));*/
$this->flash('Assessment has
been saved.','/users/admin');
}
}
} else {
$this->redirect('/users/logout');
}
}
- view
<span class="title">Setup assessment</span>
<p>
<span class="subtitle">Model</span>
<?php echo $html->formTag('/assessments/setup')?>
<table id="table_inside">
<tr>
<th><strong>Element Type</strong></th>
<th><strong>Element Name</strong></th>
<th><strong>Applicable</strong></th>
</tr>
<?php foreach($model as $var) { ?>
<?php
switch($var['AppraisalModel']['element_id']) {
case '1': ?>
<tr>
<td id="data_row_ml"><strong><?php echo $var['Element']['name'];
?></strong></td>
<td id="data_row_ml"><?php echo
$var['AppraisalModel']['element_name']; ?></td>
</tr>
<?php break;
case '2': ?>
<tr>
<td id="data_row">» <strong><?php echo
$var['Element']['name']; ?></strong></td>
<td id="data_row"><?php echo
$var['AppraisalModel']['element_name'];
?><?php echo $html->hidden('AssessmentModel/assessmentmodel_id',
array('value' => $var['AppraisalModel']['id'])); ?></td>
<td id="data_row"><?php echo
$html->checkbox('AssessmentModel/applicable'); ?></td>
</tr>
<?php break;
case '3': ?>
<tr>
<td id="data_row"> » <strong><?php echo
$var['Element']['name']; ?></strong></td>
<td id="data_row"><span
onclick="containerHeightA.toggle();"><i><?php
echo $var['AppraisalModel']['element_name']; ?><?php echo
$html->hidden('AssessmentModel/assessmentmodel_id', array('value' =>
$var['AppraisalModel']['id'])); ?></i></span> (click to read the
description)</td>
<td id="data_row"><?php echo
$html->checkbox('AssessmentModel/applicable'); ?></td>
</tr>
<tr>
<td id="data_row" colspan="2"><div id="container-1"><?php echo
$var['AppraisalModel']['description']; ?></div></td>
</tr>
<?php break;
case '4': ?>
<tr>
<td id="data_row"> » <strong><?php echo
$var['Element']['name']; ?></strong></td>
<td id="data_row"><span
onclick="containerHeightB.toggle();"><i><?php
echo $var['AppraisalModel']['element_name']; ?><?php echo
$html->hidden('AssessmentModel/assessmentmodel_id', array('value' =>
$var['AppraisalModel']['id'])); ?></i></span> (click to read the
description)</td>
<td id="data_row"><?php echo
$html->checkbox('AssessmentModel/applicable'); ?></td>
</tr>
<tr>
<td id="data_row" colspan="2"><div id="container-2"><?php echo
$var['AppraisalModel']['description']; ?></div></td>
</tr>
<?php break; } ?>
<?php } ?>
<tr>
<td><?php echo $html->hidden('AssessmentModel/assessment_id',
array('value' => $this->controller->Session->read('assessment')));
?><?php echo $html->submit('Save') ?></td>
</tr>
</table>
</form>
</p>
Any hint?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---