You might find it simpler to, instead creating a form, to put links
around the country names pointing to an edit method. In the edit view,
create one form to edit the table fields and one form to delete. So
you have something like:

<h1>Edit Canada</h1>

echo $form->create('Country', array('action' => 'delete');
echo $form->hidden('Country.id', array('value' => $some_var));
echo $form->submit('delete');
echo $form->end();

echo $form->create('Country', array('action' => 'edit');
...
echo $form->submit('edit');
echo $form->end();

This way, each action points directly to the corresponding method and
you only have to deal with one item at a time. I realise that this may
not be practical but it may work for you.

Regarding $some_var above, your code appears to assume that the
country IDs & names are going to line up with your counter var $i. I
may be missing something but that looks odd to me. I'd think it's be
better (if your $countries array is constructed as $id => $name) to do
it with a while like so:

foreach ($countries as $key => $name)
{
       $html->link($name, "countries/edit/${id}");
}

I've used my link suggestion but it's just as applicable to a form
setup like you have.

BTW, in your views, you don't need to put <?php ... ?> around every
line. If you don't have any HTML markup to add then you can just open
a block:

<?php
echo $form->create(array('url'=>'/countries/process'));

for($i =0; $i<$countries; $i++) {
       echo $form->hidden('Country'.$i.'.Country.id');
       echo $form->input('Country'.$i.'.Country.name');
}

echo $form->submit('Save', array('name'=>'save'));
echo $form->end();
?>

Otherwise, you're making the parser (and anyone who has to look at
your code) work a lot harder than necessary ;-)

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

Reply via email to