вот Вюха
- Код: Выделить всё
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'page-form',
'enableAjaxValidation'=>false,
)); ?>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'brend'); ?>
<?php
echo $form->dropDownList($model,'brend', Brend::all(), array(
'empty' => '',
'ajax' => array(
'update' => '#model',
'type' => 'POST',
'url' => CController::createUrl('/admin/page/create'),
'data' => array('id_brend' => 'js:this.value'),
)
)); ?>
<?php echo $form->error($model,'brend'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'model'); ?>
<?php echo $form->dropDownList($model,'model', array(), array('class' => 'width150')); ?>
<?php echo $form->error($model,'model'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'conntent'); ?>
<?php $this->widget('application.extensions.ckeditor.CKEditor', array(
'model'=>$model,
'attribute'=>'conntent',
'language'=>'ru',
'editorTemplate'=>'full',
)); ?>
<?php echo $form->error($model,'conntent'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'equipment'); ?>
<?php echo $form->dropDownList($model, 'equipment', Equipment::all(), array('empty' => '')); ?>
<?php echo $form->error($model,'equipment'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Сохранить'); ?>
</div>
<?php $this->endWidget(); ?>
вот контроллер
- Код: Выделить всё
public function actionCreate()
{
$model=new Page;
$ajax = ($_POST['id_brend']);
if(!$ajax){
$ajax = 1 + $ajax;
}else{
$ajax = 0 + $ajax;
}
$user = Brend::model()->findByPk($ajax);
$userBooks = $user->modeli_auto;
$list = CHtml::listData($userBooks,
'id','model');
$data=CHtml::listData($user,'id','brend');
if(Yii::app()->request->isAjaxRequest)
{
echo CHtml::tag('option', array('value' => 0), CHtml::encode(''), true);
foreach($list as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
Yii::app()->end();
}
if(isset($_POST['Page']))
{
$model->attributes = $_POST['Page'];
if($model->save())
$this->redirect(array('view','id'=>$model->id,));
}
$this->render('create',array(
'model'=>$model,
));
}