⚠ 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

Entreprise : Issue found with setRelation and bracets (solution found)



NadimD
  • profile picture
  • Member

Posted 12 January 2019 - 01:31 AM

Hello,

 

Just to let you know that using multiple fields with setRelation as the following doesn't work with 2.6.11 :

$crud->setRelation('admin_id', 'users', '{id} - {first_name} {last_name}');

Error given in AJAX request :

Warning: strstr() expects parameter 1 to be string, array given in :
\vendor/grocerycrud/enterprise/src/GroceryCrud/Core/State/StateAbstract.php (line 954)

Problem is an array is given to strstr. This array contains :

  • id
  • first_name
  • last_name

 

My workaround was to add this at before the return in the function hasMultipleFields :

if(is_array($titleField))
    	$titleField = implode($titleField);

Please let me know if you don't want me to publish the name of your functions like I just did. I did it in order to help you maintain your plugin because I love it and want to help !

 

Best regards


larasmith
  • profile picture
  • Member

Posted 14 January 2019 - 02:56 AM

Hello,

 

Just to let you know that using multiple fields with setRelation as the following doesn't work with 2.6.11 :

$crud->setRelation('admin_id', 'users', '{id} - {first_name} {last_name}');

Error given in AJAX request :

Warning: strstr() expects parameter 1 to be string, array given in :
\vendor/grocerycrud/enterprise/src/GroceryCrud/Core/State/StateAbstract.php (line 954)

Problem is an array is given to strstr. This array contains :

  • id
  • first_name
  • last_name

 

My workaround was to add this at before the return in the function hasMultipleFields :

if(is_array($titleField))
    	$titleField = implode($titleField);

Please let me know if you don't want me to publish the name of your functions like I just did. I did it in order to help you maintain your plugin because I love it and want to help !

 

Best regards

 

Hello there NadimD!

 

What file did you modify? Thanks!


NadimD
  • profile picture
  • Member

Posted 14 January 2019 - 03:03 AM

Greetings !

 

If you are using Entreprise Edition, it will be in the file :

vendor/grocerycrud/enterprise/src/GroceryCrud/Core/State/StateAbstract.php at line 953

Under the function hasMultipleFields .

 

I'm also working on a patch to allow you to search related data if you use custom fields with brackets {} (multiple brackets too).

 

Since you're an active user, could you tell me if we are allowed to modify the code and share solutions ? I'm really want to improve the plugin and add more patches!

 

Also feel free to tell me if you discover a glitch after applying any of my patches, that would help me to improve them.

You'll find more info about the patch I'm working on here : /topic/136670-question-about-the-docs-for-setmodel/?p=148930

Might interested you !


larasmith
  • profile picture
  • Member

Posted 16 January 2019 - 05:39 AM

Hi @NadimD,

 

Glad to meet someone who's also active in this community. Thank you for sharing your knowledge.

 

You can modify the code and test it in your GroceryCRUD installations. However, it would be beneficial to all if you let everyone including the developer

know the files you changed its purpose and the effect. If it does contribute beneficial functions to the CRUD itself, @web-johnny would include it in the next release.

 

If you do changes in the GroceryCRUD's core on your own and not share it and a new version was released, obviously the changes you contributed would not be in that version.

 

Again I highly appreciate and look to more contributions of you to GroceryCRUD. I'll check the link you posted here later.

 

Cheers! Happy GCruding!  :)