【发布时间】:2014-01-15 18:29:26
【问题描述】:
我在yii中使用fancybox作为表单,问题是当我提交表单时,动作被加载到fancy box中,我想要的是关闭fancy box并在正常页面中打开动作,怎么能我这样做是我的 yii 代码
调用fancybox
<?php
$this->widget('application.extensions.fancybox.EFancyBox', array(
'target' => 'a#update',
'id' => 'referrallink',
'config' => array(
'type' => 'iframe',
'width' => 500,
'height' => 500,
'titleShow'=>true,
'hideOnContentClick'=>true,
'autoScale'=>true,
),));
?>
查看
`
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'merchant-form',
'enableAjaxValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions' => array('enctype' => 'multipart/form-data')
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php //echo $form->errorSummary($model);
?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name',array('class'=>'signupField','autofocus'=>true),array('size'=>40,'maxlength'=>40))." ".$form->error($model,'name',array('style'=>'display:inline')); ?>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array('class'=>'submitbutton'/* ,'onclick'=>'parent.$.fancybox.close();' */)); ?>
</div>
<?php $this->endWidget(); ?>
</div>
控制器
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if(isset($_POST['Merchant']))
{
$model->attributes=$_POST['Merchant'];
$dir='images/merchant';
if($model->save())
{
unlink($model->logo);
$id=$model->id;
$file=CUploadedFile::getInstance($model,'logo');
$fname="$dir/$id.{$file->getExtensionName()}";
$file->saveAs($fname);
$model->saveAttributes(array('logo'=>$fname));
//die($model->password);
$this->redirect(array('view','id'=>$model->id));
}
}
$this->render('update',array(
'model'=>$model,
));
}
【问题讨论】: