<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
nmac@nicoandra.com.ar
Blog | CV | Flickr | Del.icio.us | LastFM
On Tue, Sep 1, 2009 at 9:21 AM, WebbedIT <paul@webbedit.co.uk> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment