⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Custom read fields



Paul Savostin
  • profile picture
  • Member

Posted 14 July 2015 - 16:13 PM

Did anybody face with problems when you need to add a custom read field?

Now I getting next error

 


A PHP Error was encountered

Severity: Notice

Message: Undefined index: test

Filename: libraries/Grocery_CRUD.php

Line Number: 4368

Where "test" is a custom read field. Folow to the 4368 line in GC library we found next code

 

protected function get_read_fields()
	{
		if($this->read_fields_checked === false)
		{
			$field_types = $this->get_field_types();
			if(!empty($this->read_fields))
			{
				foreach($this->read_fields as $field_num => $field)
				{
					if(isset($this->display_as[$field]))
						$this->read_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $this->display_as[$field]);
					else
line 4368					$this->read_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $field_types[$field]->display_as);
				}
			}
			else
			{ 
and so on.....

Why this error throws - because $field_types array doesnt have "test" field so $field_types[$field] index doesnt exist!

Next look at the $this->get_field_types() function where we get field types line 41

There you can see that it handles $this->basic_model->get_field_types_basic_table() fields , $this->relation_n_n fields, $this->add_fields and $this->edit_fields but NOT READ fields!


So I wonder why dont just add here $this->read_fields that will resolve the above error!

Or I missing something?

 


Amit Shah
  • profile picture
  • Member

Posted 15 July 2015 - 19:21 PM

Hi Paul,

 

Long time no see...

can you upload the code some place and avail access to the same so i may look into it.. unless u dont mind sharing the secret ;)

 

i really dont see any such problem using the same function.. never .. but it seems interesting to solve such thing ...

but 1 thing 4 sure.. u can buzz me up on weekend .. and thats the only time u can expect me 2 be around 2 look into the same..


Paul Savostin
  • profile picture
  • Member

Posted 15 July 2015 - 21:35 PM

Hi Amit! Thanks for answer

Yeah, so long time no see.. Where are u have been? :) So busy?

By my post, yes, mb I will do such things u sad. And this is really very interesting question for me... I just add checking for read fields and everything works fine! But why nobody knows?