Код: Выделить всё
<?php
/* @var $this CommentController */
/* @var $model Comment */
/* @var $form CActiveForm */
?>
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'file-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<div class="span7 offset">
<div class="row">
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textField($model,'name',array('size'=>80,'maxlength'=>256)); ?>
<?php echo $form->error($model,'name'); ?>
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'submit',
'label'=>'Load',
'type'=>'danger', // null, 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'size'=>'small', // null, 'large', 'small' or 'mini'
)); ?>
</div>
</div>
<?php $this->endWidget(); ?>
Код: Выделить всё
<?php $this->renderPartial('/comment/_form',array(
'model'=>$comment,
)); ?>
Код: Выделить всё
<?php
/**
* This is the model class for table "tbl_comment".
*
* The followings are the available columns in table 'tbl_comment':
* @property integer $id
* @property string $content
* @property string $create_time
* @property integer $profile_id
* @property integer $status
* @property integer $user_id
*/
class Comment extends CActiveRecord
{
const STATUS_PENDING=1;
const STATUS_APPROVED=2;
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'tbl_comment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
//array('content', 'required'),
//array('profile_id, status, user_id', 'numerical', 'integerOnly'=>true),
//array('content', 'length', 'max'=>256),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
// array('id, content, create_time, profile_id, status, user_id', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'author' => array(self::BELONGS_TO, 'User', 'user_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'content' => 'Content',
'create_time' => 'Create Time',
'profile_id' => 'Profile',
'status' => 'Status',
'user_id' => 'User',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
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('content',$this->content,true);
$criteria->compare('create_time',$this->create_time,true);
$criteria->compare('profile_id',$this->profile_id);
$criteria->compare('status',$this->status);
$criteria->compare('user_id',$this->user_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Comment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
//перед сохранение записать юзер ид и профиль ид
/* public function beforeSave ()
{
if($this->isNewRecord)
{
//$this->user_id;
//$this->frofile_id;
}
return parent::beforeSave();
}*/
}