Hi group

I'm sure I've asked this before but, to save time (yours and mine!),
I'm going to simplify this.

My company sends out engineers to work on customer sites.
When they get to site, they can do one of many things.

I have listed each action in a table of its own, each scheduled visit
in a table of its own and each engineer in a table of its own.

I have created a form with multiple select boxes[1] which I can select
each of my options; this works fine.
My problem comes when I try to save this data.

If I print the output of $this->data, I get
Array
(
    [Visitaction] => Array
        (
            [visit_id] => 7
        )

    [Actiontypes] => Array
        (
            [id] => Array
                (
                    [0] => 2
                    [1] => 3
                )

        )

)

My Visitaction table has fields for the visit_id and for actiontype_id
but I'm unsure how cake would store multiple selections. I know I
could do this by having a YES/NO type field for each possible action
within each visit but this seems to be very wasteful.
The other thing I could potentially do is to write a loop and save
multiple records for each actiontype selected; however, I'm sure there
_MUST_ be a better way.....I've just yet to find it.


Can you help ?


Thanks
J



[1] Code segments
The php code in the view looks like:
        <?php echo $form->create('Visitaction', array('action'=>'/
add')); ?>
        <table class="clear">
          <input type="hidden" name="data[Visitaction][visit_id]"
value="<?php e
cho $visitid; ?>" id="VisitactionVisitId">
          <tr>
            <td><?php echo $form->select('Actiontypes.id',
$actiontypes, null, a
rray('multiple'=>'checkbox')); ?></td>
          </tr>
        </table>
        <table class="clear">
          <tr>
            <?php echo $form->end('Update File'); ?>
          </tr>
        </table>


which creates html like:
        <form id="Visitaction/addForm" method="post" action="/
visitactions/add"><fieldset style="display:none;"><input type="hidden"
name="_method" value="POST" /></fieldset>        <table class="clear">
          <input type="hidden" name="data[Visitaction][visit_id]"
value="7" id="VisitactionVisitId">
          <tr>
            <td><input type="hidden" name="data[Actiontypes][id]"
value="" id="ActiontypesId" />
<div class="checkbox"><input type="checkbox" name="data[Actiontypes]
[id][]" value="1" id="ActiontypesId1" /><label
for="ActiontypesId1">Action 1</label></div>

<div class="checkbox"><input type="checkbox" name="data[Actiontypes]
[id][]" value="2" id="ActiontypesId2" /><label
for="ActiontypesId2">Action 2</label></div>
<div class="checkbox"><input type="checkbox" name="data[Actiontypes]
[id][]" value="3" id="ActiontypesId3" /><label
for="ActiontypesId3">Action 3</label></div>
<div class="checkbox"><input type="checkbox" name="data[Actiontypes]
[id][]" value="4" id="ActiontypesId4" /><label
for="ActiontypesId4">Action 4</label></div>
</td>
          </tr>
        </table>
        <table class="clear">
          <tr>

            <div class="submit"><input type="submit" value="Update
File" /></div></form>          </tr>
        </table>

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

Reply via email to