How to create/save more Model inputs and make them repeatable with jQuery

Comparing #3 with #4

Revision #4 was created by StErMi StErMi on Apr 30, 2009, 8:17:21 AM.

Added save(false) and CUploadedFile::getIstance()

Content

[...]
// This is the crappy part of the script that I need to improve and make it more elegance
// I've to add to the photoEvent array a new PhotoEvent for every istance in $_POST['PhotoEvent']
foreach ( $_POST['PhotoEvent'] as $i => $photo ) {
$photosEvent[$i] = new PhotoEvent;
if ( isset( $_POST['PhotoEvent'][$i] ) )
$photosEvent[$i]->
attributes = $_POST['PphotoUrl = CUploadedFile::getIstance($photosEvent'][$i];         , "photoUrl[$i]" ); $valid = $valid && $photosEvent[$i]->validate(); } if( $valid && $event->save(false) ) {
Yii::import('application.extensions.image.Image');
// Saving each period ( i've to change the date format couse in Italy we use dd/mm/yyyy
[...]
$image->save();
*/
$photo->save(
false);
}


$this->redirect(array('show','id'=>$lastminute->id));
[...]