⚠ 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

callback_after_update has a json error when custo felds are added



carlosT
  • profile picture
  • Member

Posted 24 May 2015 - 19:05 PM

Hello I have been using grocery crud for years now, and its still the most awesome thing ever!

 

I have recently encountered a problem. I have a field called password but i do not want it to show when editing. Instead I add 2 fields change_password and confirm_password. If they are not empty and they match it will change the real password via the callback.

 

The problem is with these two fields added and the callback after update i get...

 

SyntaxError: JSON.parse: unexpected character at line 2 column 2 of the JSON data

 

Even if the callback is a completely empty function. Without the 2 extra fields the callback works fine. Admitedly I am still using GC 1.3 because I have made a lot of small changes to the core but nothing that should effect this.

 

Any ideas?


Amit Shah
  • profile picture
  • Member

Posted 25 May 2015 - 09:32 AM

Hi carlosT

 

it is bound to have the error because the GC will build the insert statement for all the field specified. Now the custom fields when u set it.. you have to make sure you remove the same from post_array ... and return the same for processing

for the same - you need to make a callback_before_insert ...

there - process the data from extra / custom fields and remove the same from post_array..

then it wont give you the error

 

Happy GCing :)