Guys, thanks for your reply. Right now my SVN server is down :( so I can't try this snippet. I was too focused in a CakePHP way that I forgot to try this easy possibility.
Thanks guys! n. On Sat, Aug 29, 2009 at 5:14 AM, Aivaras <[email protected]> wrote: > Hey, > > well, you can always do the following echo $form->input('whatever', > array('name' => 'data[Blogurl][url][]')); > > to get your desired names. > > If you want to append inputs on button click you will have to use > javascript. Since I prefer jQuery, the code would be: > > $("#button_id").click(function(){ > $("#holder_id").append('<input type="text" id="BlogurlUrl1" > name="data[Blogurl][url][]">'); > }); > > > Hope this helps! > Faifas > > > > On Sat, Aug 29, 2009 at 02:42, nMac <[email protected]>wrote: > >> Guys, >> >> I'm working in a project where many URLs can be entered for a blog. Let's >> say Blog hasMany Blogurls; and I would like to show the well known "add >> more" link to the form so user can add new URL fields when all are filled. >> >> As far as I know, this code: >> >> echo $form->input('Blogurl.url.1', array('label' => 'Other URL')); >> echo $form->input('Blogurl.url.2', array('label' => 'Other URL')); >> echo $form->input('Blogurl.url.3', array('label' => 'Other URL')); >> >> Will work creating this: >> >> <input type="text" id="BlogurlUrl1" name="data[Blogurl][url][1]"> >> <input type="text" id="BlogurlUrl2" name="data[Blogurl][url][2]"> >> <input type="text" id="BlogurlUrl3" name="data[Blogurl][url][3]"> >> >> >> To add more, I would like to get Cake to generate this kind of input: >> >> <input type="text" id="BlogurlUrl1" name="data[Blogurl][url][]"> >> <input type="text" id="BlogurlUrl2" name="data[Blogurl][url][]"> >> <input type="text" id="BlogurlUrl3" name="data[Blogurl][url][]"> >> >> >> So I can write one of them inside a display:none'd DIV and append it when >> the user clicks on the Add More button. >> >> >> >> I can't find the proper way to do this. I thought in apply some JS >> modifications in the original field and then append it's code to the form; >> but will be very messy. >> >> >> >> Other choice is to make a small modification in the framework, or extend >> the Helper class; but I know this is not a good idea. >> >> What do you think? Have you ever seen yourselves in this situation? >> >> Thanks and happy coding. >> >> >> >> >> >> 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_> >> >> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
