Here's what I've done in the view:
<div id="BlogUrls">
<?
$i = 0;
for($i = 0; $i < sizeof($this->data['Blogurl']['url']); $i++){
echo $form->input("Blogurl.url.$i", array('label' => 'URL'));
}
?>
</div>
<div id="BlogUrlRow" style="display: none;">
<?echo $form->input('BlogurlUrl', array('name' =>
'data[Blogurl][url][]','id' => '', 'label' => 'URL'));?>
</div>
<a href="#"
onclick="$('#BlogUrls').append($('#BlogUrlRow').html());"><?__('Add
URL');?></a>
In controller, I had to validate manually each URL since the saveAll()
method won't work because of the non-conventional field names.
May be there's a better solution to deal with this problem if you know
exactly how many URLs you're expecting to receive; but in this case user may
add many URLs as he desires.
Of course guys *don't do this at home; and ensure you're under an adult
supervision if you want to do it;* and always remember to use Cake
conventions and methods (that's why we are using a framework).
Thanks guys for your help and cooperation!
Nicolás Andrade
*[email protected]*
Blog <http://www.nicoandra.com.ar> | CV <http://nandrade.awardspace.com> |
Flickr <http://www.flickr.com/photos/aanm> |
Del.icio.us<http://del.icio.us/nis_>|
LastFM <http://www.lastfm.es/user/nis_>
On Tue, Sep 1, 2009 at 9:21 AM, WebbedIT <[email protected]> wrote:
>
> eh? why refuse to name the fields using CakePHP's conventions ...
> effectively stopping you from using the perfectly good saveAll()
> method to save both your Blog and multiple BlogUrl data with full
> validation all in one call? Are you confident that you can write a
> better function than the one already in the core?
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---