Jump to content


NadimD's Content

There have been 13 items by NadimD (Search limited from 15-October 18)


By content type

See this member's

Sort by                Order  

#148994 Replace url filename with custom text

Posted by NadimD on 30 January 2019 - 01:41 PM in I have a question

You're welcome !

 

Well, to make a callback on the clicked link, that would be out of Grocery Crud since the click is handle by the browser.

That means you could either add a onclick='yourcallback();' on your link, and make a JS function yourcallback() , or you can init a click event with jQuery, outside GroceryCRUD.

 

Make sure you load jQuery or any library you use to handle the clicks if you use a library, and that's it !

If the callback is supposed to happen after the link is clicked, on the target, that would be server-side !

 

Let me know if you understand and feel free to provide me more details.

 

I personnally don't want to get into the GCRUD React scripts, they can be updated any time and I'm not a React developer, so I handle everything else in my own script.js using jQuery.

 

That's how I made a "preview" button for instance, I have a table "articles" with a text field, and I added a preview button near the Save button to achieve custom events.




#148983 Question about the docs for setModel

Posted by NadimD on 27 January 2019 - 01:58 AM in I have a question

All right, I'm currently far from home and I don't have my computer with me, I will be back next week and will notify you here when the patch is released, sorry for the delay but I cannot do better than that atm!




#148966 Question about the docs for setModel

Posted by NadimD on 23 January 2019 - 12:20 PM in I have a question

What version are you using ? I will provide you my fixes according asap




#148947 Replace url filename with custom text

Posted by NadimD on 21 January 2019 - 12:28 AM in I have a question

Greetings !

 

You can use a callback on the column to achieve that :

 

https://www.groceryc...callback_column

 

Let me know if this works for you.




#148945 Question about the docs for setModel

Posted by NadimD on 18 January 2019 - 11:51 PM in I have a question

Thank you @larasmith .

 

I've finished my patch and will soon release a post to add :

- Search with multiple words on 1_to_N relations

- Multiple field names when using set_relation and a custom display

 

I just need to optimize a little bit the code before releasing it, you'll be notified in this post aswell.

 

Stay tuned !




#148944 pass variable into add form and insert in a different table

Posted by NadimD on 18 January 2019 - 11:37 PM in General

Hello there !

 

Did you try to add a callback to your CRUD, to force the id ?

 

Example below (for Free Edition) : https://www.groceryc...k_before_insert

$crud->callback_before_insert(array($this,'encrypt_password_callback'));

// ...

function set_id_before_insert($post_array) {
	$post_array['id'] = $your_id; 
	return $post_array;
}

Example below (for Entreprise Edition) :

$crud->callbackBeforeInsert(function ($stateParameters) {
	$stateParameters->data['id'] = $your_id; // Here you put whatever variable you use to get the id
	return $stateParameters;
});

Replace $your_id with your actual desired id. If you can't pass the variable into the function, set it in the class as a private variable like :

private $insert_id;

In your controller, get the id from the URL and set the variable like this :

$this->insert_id = $_GET['id']; // Or your actual variable

And get it in the function with :

$this->insert_id

// OR a create a getter method if you need to process the id before getting it



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

Posted by NadimD on 14 January 2019 - 03:03 AM in Bugs / Issues

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 : https://www.groceryc...model/?p=148930

Might interested you !




#148930 Question about the docs for setModel

Posted by NadimD on 13 January 2019 - 11:29 PM in I have a question

Hello John :)

 

I was reading the docs (Entreprise Edition) about callbackColumn here : https://www.groceryc.../callbackColumn

 

And I'm facing the problem you talk about. Making a custom column affects the search function and it won't work properly.

What did you mean when you said to use a setModel ? I don't see how you would use a Model in this case !

 

Could you tell me more ? Thanks ! :)

 

Update : I did a patch in order to make the search function work with a relation and its custom fields.

I will release it if you agree, but since it is Entreprise Edition, please let me know what to do with the patch.

 

That's how it works now, first I can search as always in a non related field, and I can make a callback on the column "page_id" with the name "Page associƩe" displayed here :

 

YdAAMEc.png

 

 

And I can type in multiple words, multiple "like" queries will be added to the whereStatements function and explode each keyword typed to give this result :

 

DxP6rRU.png

 

Also, spaces will be ignored so that you can make a copy&paste without worrying about formatting the text.




#148929 Question about block field after save and log user changes

Posted by NadimD on 12 January 2019 - 09:49 PM in I have a question

Hello Adrian,

 

Have you looked for callbacks into the documentation ?

Might be really helpful since you can fire you own events before/after most actions.

EG : You could add a callback to test in your code if the user should be allowed to edit/update.

 

Callbacks for the Open Source edition : https://www.groceryc...tions_functions

Callbacks for the Entreprise edition : https://www.groceryc...d-function-list




#148928 Bugs in Displaying setRelation Field when Showing More Than One Field in v.2....

Posted by NadimD on 12 January 2019 - 09:44 PM in Grocery CRUD Enterprise

Hello larasmith,

 

I'm new here and can't answer for the staff, I'm not a pro, but I'm willing to help you.

 

You could try to follow what I did here in 2.6.11 :

=> https://www.groceryc...solution-found/

 

Your problem might not be the same, so non-related, but since it's about brackets and fields, I think why not, you can always go back!

Also, could you try removing the brackets, just to see what happens, like this :

$crud->setRelation('vdr_Course', 'set_course', '{course_Title} {course_RefNo}');

Try again and leave only {course_RefNo}

 

Does that affect the display ? Is yes, you can try to use a callback, but you have to have the related field identifiable in order to make a callback on it:

https://www.groceryc.../callbackColumn

 

Set a callback on your column, get both course_Title and course_RefNo in your callback. Use the example provided in the link !




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

Posted by NadimD on 12 January 2019 - 01:31 AM in Bugs / Issues

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




#148922 Zend DB error

Posted by NadimD on 11 January 2019 - 11:04 PM in Bugs / Issues

Hello,

 

What version of Zend are you using ?




#148921 Issues installing on Symfony 4

Posted by NadimD on 11 January 2019 - 10:50 PM in Grocery CRUD Enterprise

Hello there ! :)

 

UPDATED : FOUND SOLUTION !

 

Just to let you know that I kept debugging and found out what was wrong ! :)

I will make a post to let Symfony users know how to install and use the plugin.

 

Remember this block from the examples ?

if ($output->isJSONResponse) {
    header('Content-Type: application/json; charset=utf-8');
    echo $output->output;
    exit;
}

Well in Symfony, I did the following changes, which are WRONG :

return new JsonResponse($output->output);

or

return new JsonResponse(array('output' => $output->output));

What you SHOULD do is the following, as we already have a JSON response, we need to use "fromJsonString" :

if ($output->isJSONResponse) {
	return JsonResponse::fromJsonString($output->output);
}

And that's it ! If you're having trouble, go to the official Grocery CRUD Entreprise website, open the Network tab in the Elements Inspector, refresh and look for the "initial" AJAX call.

Compare the content to the AJAX call you get on your installation. If it doesn't match, something's wrong and that's why GC won't load if everything else is loaded like mentioned bellow in the original post.

 

---

Original post :

 

 

TL;DR :

Plugin loaded into Symfony 4, rendered in a $output variable called in a Twig template, doesn't show anything and I get a JS error.
All ressources are loaded and configurations look good. No error returned. Just divs.

 

 

I purchased the Entreprise Edition, I'm a very old user of GC (since the first version).

 

I followed the steps to install it with composer and I had to adjust a few things in order to make the plugin work. (code is almost similar to Laravel but still needs to be adjusted).

 

The connection to the database works fine, ressources are loaded (JS and CSS), and the $output variable is rendering but everything stays blank, I can't see anything.

 

Looking into the Inspector shows me that the div are generated, the first AJAX call is made and works (the action: initial query), but after that, nothing happens.

 

Still, I'm getting a JS error in the console :

 

 

Uncaught TypeError: Cannot read property 'skin' of undefined

 

Which is located there :

q5AmI4N.png

 

 

When I look into the hidden generated HTML, no columns have been created, so I'm getting nothing.

 

I tried playing with the configurations, one by one. When something's wrong, I get an error.

 

When everything's set properly, I get no error but no result.

 

What would be the cause and what can I do to debug ? I think it's not related to JS. Already tried to remove everything from the page and leave only GC and its loaded CSS/JS files.

Still nothing, the same JS error comes up and I can't figure how to make the plugin work.

 

Once I have figured it out, I will make a post about how to install it on Symfony.

 

Thank you for your time !

Best regards.

 

Edit : Additional info.

Note that while the HTML is rendered and empty, I can see the {{i18n.loading}} line in the following picture. Does that mean it's not rendered properly ?

 

dbLaiuQ.png

 

Symfony uses Twig, not Blade, but I see no reason that would be a problem.