Ive got a form which adds a text fields dynamically when i want to add more records to a one to many relationship table.. for example movie has more than one video.. i can get one record to add but cant seem to get the rest to work...

form --

<div class="row clone">
    <?php echo $form->labelEx($modelYoutubeVideo,'embed_code'); ?>
    <?php echo $form->textField($modelYoutubeVideo,'embed_code',array('size'=>50,'maxlength'=>50)); ?>
    <?php echo $form->error($modelYoutubeVideo,'embed_code'); ?>

    <?php echo $form->labelEx($modelYoutubeVideo,'description'); ?>
    <?php echo $form->textField($modelYoutubeVideo,'description',array('size'=>50,'maxlength'=>250)); ?>
    <?php echo $form->error($modelYoutubeVideo,'description'); ?>
         $this->widget('ext.widgets.reCopy.ReCopyWidget', array(

Controller --

    if( isset( $_POST['YoutubeVideo']['embed_code'] ) ) {

                    for($i=0; $i<count( $_POST['YoutubeVideo']['embed_code'] ); $i++) {

                        $modelYoutubeVideo = new YoutubeVideo();

                        $modelYoutubeVideo->embed_code = $_POST['YoutubeVideo']['embed_code'][$i];
                        $modelYoutubeVideo->description = $_POST['YoutubeVideo']['description'][$i];
                        $modelYoutubeVideo->movie_id = $model->id;



Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top