(I post here also because I see nobody answering in the other section)
I need to add some custom fields in the view page and obviusly populate them with a callback function for the read mode. I have not found any reference to functions for adding fields in read page in grocery crud documentation; just a reference in a very old topic here mentioning the function set_read_fields that i cannot find after 5 years from that forum topic in the decumentation. Anyway, even if the function gives no errors, when the callback function is called i got a lot of errors; here the log
ERROR - 2020-07-22 17:26:28 --> Severity: Notice --> Undefined index: officies_location /home/phar263d/public_html/adminPanel/application/libraries/Grocery_CRUD.php 4477
This is the code i used
$this->grocery_crud-
>add_fields('id','vendor_name','vendor_web_site_url','default_currencies_id','affiliation_category','external_affiliation_services_id','affiliation_vendor_id','remark','last_modified','creation','enabled'); $this->grocery_crud->edit_fields('id','vendor_name','vendor_web_site_url','default_currencies_id','affiliation_category','external_affiliation_services_id','affiliation_vendor_id','remark','last_modified','creation','enabled'); $this->grocery_crud->set_read_fields('id','vendor_name','vendor_web_site_url','default_currencies_id','affiliation_cate...gory','external_affiliation_services_id','affiliation_vendor_id','remark','last_modified','creation','enabled','officies_location'); [...] $this->grocery_crud->callback_read_field('officies_location',array($this,'_callback_officies_location'));
The callback function is fine (tested); tracking the error i found out that it happens when the rendering function is called
$output = $this->grocery_crud->render();
Any ideas? Thanks.
UPDATE 1
you guys it seems that the new field should be added in $field_types array because it is needed the display_as variable. It seems a real bug.
UPDATE 2
Just first two errors on line 4477can be skipped (but it is just a workaround on the core problem) if the new read only field is passed to the display_as() function.
UDAPTE 3
in get_field_types(){..} it seems missing a block like these
if(!empty($this->add_fields)) foreach($this->add_fields as $field_object) { .... } if(!empty($this->edit_fields)) foreach($this->edit_fields as $field_object) { ... }
for the read_fields so that these are never added to the main data structure $this->field_types. Please could somebody check this?