Оу, думал уже никто не ответит
Т.е. включить логи? Те, что внизу страницы? Ведь если не перенаправлять страницу страницу с аттрибутом termanate=true, то всё сохраняется.
Вот сама модель (одна из, т.к. это касается всех моделей):
Код: Выделить всё
<?php
/**
* This is the model class for table "project_stage_report".
*
* The followings are the available columns in table 'project_stage_report':
* @property integer $id
* @property integer $project_stage_id
* @property string $description
*
* The followings are the available model relations:
* @property ProjectStage $projectStage
*/
class ProjectStageReport extends ActiveRecord
{
public function tableName()
{
return 'project_stage_report';
}
public function rules()
{
return array(
array('project_stage_id, description', 'required'),
array('project_stage_id', 'numerical', 'integerOnly' => true),
array('description', 'length', 'max' => 45),
array('id, project_stage_id, description', 'safe', 'on' => 'search'),
);
}
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'projectStage' => array(self::BELONGS_TO, 'ProjectStage', 'project_stage_id'),
);
}
public function attributeLabels()
{
return array(
'id' => 'ID',
'project_stage_id' => 'Project Stage',
'description' => 'Description',
);
}
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('project_stage_id', $this->project_stage_id);
$criteria->compare('description', $this->description, true);
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
));
}
public static function model($className = __CLASS__)
{
return parent::model($className);
}
}
Вот часть контроллера для редактирования, например:
Код: Выделить всё
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$this->performAjaxValidation($model);
if (isset($_POST['ProjectStageReport'])) {
$model->attributes = $_POST['ProjectStageReport'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('update', array(
'model' => $model,
));
}
Вот сама форма:
Код: Выделить всё
<div class="form">
<?php $form = $this->beginWidget('CActiveForm', array(
'id' => 'project-stage-report-form',
'enableAjaxValidation' => true,
'enableClientValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'focus' => array($model, 'login'),
)); ?>
<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, 'description'); ?>
<?php echo $form->textField($model, 'description', array('size' => 45, 'maxlength' => 45)); ?>
<?php echo $form->error($model, 'description'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton(Yii::t('app', $model->isNewRecord ? 'Create' : 'Save')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Ещё есть прослойка ActiveRecord, но файл, можно сказать пустой:
Код: Выделить всё
class ActiveRecord extends CActiveRecord
{
const SCENARIO_CREATE = 'insert';
const SCENARIO_UPDATE = 'update';
const SCENARIO_SEARCH = "search";
public static function model($className = __CLASS__)
{
return parent::model($className);
}
}
Ну и сам конфиг:
Код: Выделить всё
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=docs',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
),