⚠ 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

callbackColumns $row error: Undefined index



Marty
  • profile picture
  • Member

Posted 18 September 2017 - 09:51 AM

Grocerycrud Enterprise version 2.3.1., updated to 2.3.3

 

Even though the table contains the field event_url, following code

 

$crud->columns(
['name', 'event', 'event_datetime', 'source']
);

 

$crud->callbackColumn(
'event', function ($value, $row) {
// print_r($row);
return "<a href='". $row->event_url. "' target='blank'>$value</a>";
}
);

 

will result in an error: Undefined index: event_url 

 

When 'event_url' is added to columns the callbackColumn function works?!

 

In the documentation $row value's are used without being listed as a column.

 

And with this remark in the callbackColumn documentation:

 

"2. The whole row as an object. In simple words you have access to any of the data at this row in case you need to combine other parameters at the same row."

 

I assumed that I can access all fields in the table row even the ones that are not listed?

 

How can I create a column with links without having/displaying the url column in the view?

 

Thanks in advance.


Marty
  • profile picture
  • Member

Posted 21 September 2017 - 14:12 PM

Is this a bug or am I doing something wrong?

 

Anyone?

 

The GroceryCRUD Enterprise author is clearly not interested in answering questions..


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 21 September 2017 - 18:39 PM

Hello Marty,

 

First of all I am sorry that you did mistakenly think that I am not interested in answering questions. In fact as my time is very limited I am trying to organise myself in order to answer more questions by having a backlog. Usually my average time of responding is 1 week but unfortunately if the questions are more it may even take 2 weeks (!) for a question to be answered. My main priority are the questions over email. Questions in the forums are also there so other users can help with faster replies and for me to also have more time in order to improve all of the products that I have.

 

Now to answer your question as far as I've checked this is a bug and I will have it as priority to get it solved. I will try to have it for the next version that the estimation is 16 October (or earlier). I will inform this post once this is done. If it is really urgent for you and you can't wait till then as a work-around you can use a custom model (for more check https://www.grocerycrud.com/enterprise/examples-3/create-custom-model)

 

Regards

Johnny


Marty
  • profile picture
  • Member

Posted 22 September 2017 - 07:23 AM

Hi Johnny,

 

Thanks for your response, all clear now. Maybe something to put in the forum description header so (new) people like me know this upfront when asking questions. It got little frustrated seeing a newer question being answered and a simple 3 days old question left untouched.

 

Regarding the callbackColumn bug, for now I have a temporary workaround. Awaiting the new version. Would be nice though to have an overview with already reported/known bugs.

 

Regards,

Marty


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 02 October 2017 - 18:29 PM

Hello Marty,

 

This is now fixed at the latest version of Grocery CRUD Enterprise (version 2.3.4).

 

The backlog tracking is something that it is still in experimental mode and I will need more time in order to organise better the flow in order to make it transparent to everyone. 

 

Regards

Johnny


Sorin Sfirlogea
  • profile picture
  • Member

Posted 06 January 2021 - 14:16 PM

Apparently this bug reappeared in version 2.8.7.

$crud->columns( ['document_number', 'document_date', 'partner_id', 'product_id', 'quantity', 'amount', 'special_location'] );

$crud->callbackColumn( 'amount', function( $value, $row) {
  return $value . ' ' . getCurrencyCodeByID( $row->currency_id );
});

If I don't include currency_id field in the displayed columns, I get an undefined index error.

Could you please take a look into it?