Hi guys, I need help…
I have controller like this :
public function actionCreate()
{
$model=new Playlist;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Playlist']))
{
$model->attributes=$_POST['Playlist'];
if($model->save())
if (isset($_POST['playlist_id'])) {
$total = count($_POST['storage']);
for ($i = 0; $i <= $total; $i++) {
if (isset($_POST['storage'][$i])) {
$model4 = new Playlistdetail;
$model4->storage_id = $_POST['storage'][$i];
$model4->playlist_id =$model->id;
$model4->save();
}
}
}
$this->redirect(array('/playlist/admin'));
}
$this->render('create',array(
'model'=>$model,
));
}
and view/_form like this :
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
'id'=>'playlist-form',
'enableAjaxValidation'=>true,
)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textFieldRow($model,'playlistname',array('class'=>'span5','maxlength'=>100)); ?>
<div class='span5'>
<?php $songsData =new CActiveDataProvider('Storage');
$this->widget('bootstrap.widgets.TbJsonGridView',array(
'type'=>'striped bordered condensed',
'id'=>'storage-grid',
'dataProvider'=>$songsData,
'selectableRows'=>2,
'columns'=>array(
array(
'class'=>'bootstrap.widgets.TbJsonCheckBoxColumn',
'value'=>'$data->id',
'checkBoxHtmlOptions' => array(
'name' => 'storage_id',
),
),
'id',
'filesong',
),
)); ?>
<div class="form-actions">
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'submit',
'type'=>'primary',
'label'=>$model->isNewRecord ? 'Create' : 'Save',
)); ?>
</div>
<?php $this->endWidget(); ?>
</div>
There is no error but can’t save the values to databases
so how can it work…sorry if I’m newbie.
Thanks In Advance.