Create customized field value Yii2

hello! After a long hiatus. I got a project for my office. It is a dashboard application for powerdns. All the records  have only 1 master domain. So, I have to do a trick to put trustpositifkominfo as a domain for every record inserted. here is the magic:

public function beforeSave($insert) {

if ($insert) {
$this->domain_id = 1;
$this->name = $this->name.’.trustpositifkominfo’;
}
return parent::beforeSave($insert);

}

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s