Skip to content

Deprecated since 7.2

This page documents the classic module layer (CBController and cbInit()). It still works in every 7.x release, but new code should use resources and pages.

Use instead: beforeCreate(array $data) and beforeUpdate(array $data, $record) on the resource.

How To Inject A Post Data In Create/Update/Delete Data Process ​

Products Table - products ​

Field NameDescription
idint(PK)
created_attimestamp
namevarchar(255)
descriptiontext
statusvarchar(25)

Make a pre-custom-data at Create A Data ​

php
public function hook_before_add(&$postdata) {  
  //For example you want to override the status field
  $postdata['status'] = 'Active';
}

This method will be called once submitting a form in Create A Data.

Make A Pre-Custom-Data at Update A Data ​

php
public function hook_before_edit(&$postdata,$id) {  
  //For example you want to override the status field
  $postdata['status'] = 'Active';
}

This method will be called once submitting a form in Update A Data.

Make A Pre-Custom-Data at Delete A Data ​

php
public function hook_before_delete($id) {  
  //You want to delete all data of child table
  DB::table('OTHER_CHILD_TABLE')->where('FOREIGN_KEY',$id)->delete();  
}

This method will be called once delete button is clicked.

What's Next ​

Table Of Contents ​

Released under the MIT License.