I have a "BTeam" model class with attributes id, name, created. I generated this with Gii.
I added "TimestampBehavior" which fills the "created" field during model creation with the current timestamp.
How can I remove the field from the "add" page:
My BTeam class:
<?php
namespace app\models;
use Yii;
use yii\db\ActiveRecord;
class BTeam extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'b_team';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['created'], 'safe'],
[['name'], 'string', 'max' => 200]
];
}
public function behaviors() {
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created']
]
]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
'created' => 'Created',
];
}
}