Beispiel #1
0
 protected function make_crud()
 {
     $crud = parent::make_crud();
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: You can access this variables after calling parent's make_crud method:
     //      $this->CRUD
     //      $this->STATE
     //      $this->STATE_INFO
     //      $this->PK_VALUE
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // set subject
     $crud->set_subject('Commodity');
     // displayed columns on list, edit, and add, uncomment to use
     //$crud->columns('name');
     //$crud->edit_fields('name', '_updated_by', '_updated_at');
     //$crud->add_fields('name', '_created_by', '_created_at');
     // caption of each columns
     $crud->display_as('name', 'Name');
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // This function will automatically detect every methods in this controller and link it to corresponding column
     // if the name is match by convention. In other word, you don't need to manually define callback.
     // Here is the convention (replace COLUMN_NAME with your column's name)
     //
     // * callback column (called when viewing the data as list):
     //      public function _callback_column_COLUMN_NAME($value, $row){}
     //
     // * callback field (called when show add and edit form):
     //      public function _callback_field_COLUMN_NAME($value, $primary_key){}
     //
     // * validation rule callback (field validation when adding/editing data)
     //      public function COLUMN_NAME_validation($value){}
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $this->build_default_callback();
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put required field validation codes here
     // (documentation: http://www.grocerycrud.com/documentation/options_functions/required_fields)
     // eg:
     //      $crud->required_fields( $field1, $field2, $field3, ... );
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $crud->required_fields('name');
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put required field validation codes here
     // (documentation: http://www.grocerycrud.com/documentation/options_functions/unique_fields)
     // eg:
     //      $crud->unique_fields( $field1, $field2, $field3, ... );
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $crud->unique_fields('name');
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put field validation codes here
     // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_rules)
     // eg:
     //      $crud->set_rules( $field_name , $caption, $filter );
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put set relation (lookup) codes here
     // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation)
     // eg:
     //      $crud->set_relation( $field_name , $related_table, $related_title_field , $where , $order_by );
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put set relation_n_n (detail many to many) codes here
     // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n)
     // eg:
     //      $crud->set_relation_n_n( $field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table,
     //          $primary_key_alias_to_selection_table , $title_field_selection_table, $priority_field_relation );
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put custom field type here
     // (documentation: http://www.grocerycrud.com/documentation/options_functions/field_type)
     // eg:
     //      $crud->field_type( $field_name , $field_type, $value  );
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put Tabs (if needed)
     // usage:
     //     $crud->set_outside_tab($how_many_field_outside_tab);
     //     $crud->set_tabs(array(
     //        'First Tab Caption'  => $how_many_field_on_first_tab,
     //        'Second Tab Caption' => $how_many_field_on_second_tab,
     //     ));
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Create custom search form (if needed)
     // usage:
     //     $crud->unset_default_search();
     //     // Your custom form
     //     $html =  '<div class="row container col-md-12" style="margin-bottom:10px;">';
     //     $html .= '</div>';
     //     $html .= '<input name="keyword" placeholder="Keyword" value="'.$keyword.'" /> &nbsp;';
     //     $html .= '<input type="button" value="Search" class="crud_search btn btn-primary form-control" id="crud_search" />';
     //     $crud->set_search_form_components($html);
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put callback here
     // (documentation: httm://www.grocerycrud.com/documentation/options_functions)
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // HINT: Put custom error message here
     // (documentation: httm://www.grocerycrud.com/documentation/set_lang_string)
     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // $crud->set_lang_string('delete_error_message', 'Cannot delete the record');
     // $crud->set_lang_string('update_error',         'Cannot edit the record'  );
     // $crud->set_lang_string('insert_error',         'Cannot add the record'   );
     $this->CRUD = $crud;
     return $crud;
 }
Beispiel #2
0
 public function _after_delete($primary_key)
 {
     $success = parent::_after_delete($primary_key);
     // HINT : Put your code here
     return $success;
 }