on_insert with image problem

Questionson_insert with image problem
Bruce Rick asked 2 years ago

I’ve been having a problem with a custom on_insert event but I think it really has to do with uploading an image. So I have the following for the event:

$e[“on_insert”] = array(“add_blob”, null, false);

This is now the function, so it literally does nothing:

function add_blob($data)
{
}

If I run the page it works fine for an insert (no it doesn’t write to the database, it just refreshes the page), but if I try to insert an image, it crashes and breaks the session ends (users is logged in). Nothing is done other than a file was uploaded, but I think there’s an issue somewhere in the on_insert function because it does not like uploading an image. It still does upload the image to the folder, which that is fine, but then it crashes on submitting the file. This is what it looks like on a crash. It’s the before submitting and after. There’s no custom code going in at this point, as I’ve deleted everything else and just attempted to see what would happen with an empty function running:

https://gist.github.com/bruceits/ca3062d723e478eb975a7116db972dc5

View post on imgur.com

4 Answers
Abu answered 2 years ago

I will be updating back after regenerating the case.

Bruce Rick answered 2 years ago

Thank you Abu. I hope it’s a quick fix or you see something goofy that I did. Every time I used the on_insert function I get this. on_delete and on_update work flawlessly, I get no problems at all. The on_insert is the only one that crashes, and then half the time it breaks my sessions and logs the user off.

Abu Ghufran Staff answered 2 years ago

Hello,

Pretty much delayed reply but I think it’s because add operation expects JSON object as return object. So if your have complete custom on_insert code (and skip grid’s insert implementation as it can be seen in your code), You also need to return a JSON object with success message from on_insert handler.

Example code mentioned in demo:

https://www.gridphp.com/demo/demos/editing/custom-events.phps#L.118-131

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Bruce Rick answered 2 years ago

Okay, thank you Abu, I’ll take a look at that and see if I can work this one out. That makes a bit of sense.

Your Answer

0 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?