Hello everyone,
I have this code:
public function render() {
// Apply filters if any
$this->applyFilters();
// Define Columns and Fields
$columns = array('code', 'name', 'fname', 'family', 'status' );
if ( $this->ci->uri->segment(3)=='edit' ){
$fields = array('name', 'surname', 'fname', 'gender', 'birth', 'address', 'zip', 'city', 'region', 'section', 'district', 'citizenship', 'phone', 'email', 'identity', 'afm', 'amka',
'family', 'education', 'education_reason', 'marital', 'protected_members', 'occupation', 'unemployment_card', 'social_security', 'income', 'income_from', 'allowances', 'profile_info',
'vulnerable', 'guardianship', 'outcast', 'learning_difficulties', 'homeless_reverse', 'homeless_reverse_way', 'history',
'family_type', 'family_head', 'residence', 'residence_size', 'residence_rooms', 'electricity', 'hot_water', 'internet', 'family_info', 'status');
}
else{
$fields = array('name', 'surname', 'fname', 'gender', 'birth', 'address', 'zip', 'city', 'region', 'section', 'district', 'citizenship', 'phone', 'email', 'identity', 'afm', 'amka',
'family', 'education', 'education_reason', 'marital', 'protected_members', 'occupation', 'unemployment_card', 'social_security', 'income', 'income_from', 'allowances', 'profile_info');
}
$this->ci->uri->segment(3) == "export" ? $this->crud->columns($fields) : $this->crud->columns($columns);
// Set Labels. We set labels upfront because we may need to overwrite a label using the traditional way
$this->setLabels($fields);
// Prepare CRUD
$this->crud
->fields($fields)
->required_fields('gender', 'name', 'birth', 'status')
->display_as('residence_size', 'ΑÏιθμός Δωματίων:')
/* Set Relations */
->set_relation('gender', '_map_genders', 'title')
->set_relation('citizenship', '_map_citizenship', 'title')
->set_relation('family','beneficiaries','{name} {surname} ({fname})', NULL, 'id ASC')
->set_relation('education', '_map_education', 'title', NULL, 'id ASC')
->set_relation('marital', '_map_marital', 'title')
->set_relation('occupation', '_map_occupation', 'title')
->set_relation('unemployment_card', '_map_unemployment_card', 'title', NULL, 'id ASC')
->set_relation('social_security', '_map_social_security', 'title')
->set_relation('income_from', '_map_income_from', 'title')
->set_relation_n_n('allowances', 'allowances_link', '_map_allowances', 'beneficiary_id', 'map_id', 'title', NULL)
->set_relation_n_n('vulnerable', 'vulnerable_link', '_map_vulnerable', 'beneficiary_id', 'map_id', 'title', NULL)
->set_relation('guardianship','beneficiaries','{name} {surname} ({fname})', NULL, 'id ASC')
->set_relation('outcast', '_map_outcast', 'title')
->set_relation('learning_difficulties', '_map_learning_difficulties', 'title')
->set_relation_n_n('indirect_income', 'indirect_income_link', '_map_indirect_income', 'beneficiary_id', 'map_id', 'title', NULL)
->set_relation_n_n('homeless_reason', 'homeless_reason_link', '_map_homeless_reason', 'beneficiary_id', 'map_id', 'title', NULL)
->set_relation_n_n('homeless_reverse_way', 'homeless_reverse_way_link', '_map_homeless_reverse_way', 'beneficiary_id', 'map_id', 'title', NULL)
->set_relation('status', 'statuses', '<span class="label {label}">{title}</span>', 'statuses.mode = "generic"');
if ( $this->ci->uri->segment(3)=='edit' ){
$this->crud
->callback_update(array($this,'callback_update'))
->callback_field('family_type', array($this,'callback_field_family_type'))
->callback_field('family_head', array($this,'callback_field_family_head'))
->callback_field('residence', array($this,'callback_field_residence'))
->callback_field('residence_size', array($this,'callback_field_residence_size'))
->callback_field('residence_rooms', array($this,'callback_field_residence_rooms'))
->callback_field('electricity', array($this,'callback_field_electricity'))
->callback_field('hot_water', array($this,'callback_field_hot_water'))
->callback_field('internet', array($this,'callback_field_internet'))
->callback_field('family_info', array($this,'callback_field_family_info'))
->callback_field('status', array($this,'callback_field_status'));
$tabs = '<ul class="nav nav-tabs" style="margin-bottom:-1px;">
<li class="active"><a data-toggle="tab" href="#beneficiary">Στοιχεία ΩφελοÏμενου</a></li>
<li><a data-toggle="tab" href="#social_worker">Στοιχεία ÎšÎ¿Î¹Î½Ï‰Î½Î¹ÎºÎ¿Ï Î›ÎµÎ¹Ï„Î¿Ï…ÏγοÏ</a></li>
<li><a data-toggle="tab" href="#family">Στοιχεία ΟικογÎνειας</a></li>
</ul>';
}
return $this->crud->render($tabs);
}
I'm struggling to transfer an array or object from this function to the assets/grocery-grud/themes/bootstrap/edit.php file.
Do you have any idea how I can do that?
I tried to create a new protected variable in grocery_crud class in libraries/grocery_crud.php but not successfully. Do you know if this is a correct way?
Thanks for the help in advance
