⚠ 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

Functions field(), edit_fields() and add_fields() prevent database updating



Fabrizio
  • profile picture
  • Member

Posted 25 June 2013 - 10:42 AM

Hello to everyone,

 

I am a very new user of GroceryCRUD framework and even following precisely the instruction to install and use it I have met the following issue:

 

when I add to my controller one of the following functions:

  • fields()
  • edit_fields()
  • add_fields()

my controller doesn't work anymore and when i try to add, edit or delete a record from the database it simply does nothing.

I attach a copy of the present code of my controller. In the comments the functions that make everything stop working.

 

Is there anyone that can help me fixing this issue?

 

Thank you so much in advance.

 

Fabrizio


davidoster
  • profile picture
  • Member

Posted 25 June 2013 - 20:51 PM

Hello and welcome to the forums [member=guidicini].

Is the field journal_id your primary key of the table?

If it is you need to http://www.grocerycrud.com/documentation/options_functions/set_primary_key


Fabrizio
  • profile picture
  • Member

Posted 26 June 2013 - 07:26 AM

Hello davidoster,

 

thank you for your advice.

I'll put it in practice as soon as I'm again working on that code and let you know if that fixed the problem.

 

Meanwhile a BIG thank you!!

 

fabrizio


Fabrizio
  • profile picture
  • Member

Posted 27 June 2013 - 07:35 AM

Hello davidoster,

 

I have set the primary key in my code as you suggested, but unfortunately it seems things doesn't work.

I explain:

 

The code I am trying has the same fileds (for now) in the edit_fields and add_fields functions. I just wanted to try to see if they work and then I would have modified the two functions.

This premised I added the set_primary_key (yes "journal_id" is the primary key of the only one table "riviste" I have for the moment) but if i try to add or edit a record the operation is not executed.

I reach the add or edit forms, I make the changes, i press the "do it" and go back to the list button but nothng happens.

 

If I comment (delete) the two functions edit_fields and add_fields everything start working again.

 

Unfortunately I have read all the possible documents, but I can't find a fix for this issue.

 

Have you any oher idea of how i could try to fix this issue?

 

Thank you again.

 

Fabrizio

 

PS: the code that doesn't work is the same controllaer above (main.php) with just one line added (set_primary_key) and the two functions edit_fields and add_fields uncommented.


davidoster
  • profile picture
  • Member

Posted 27 June 2013 - 08:18 AM

Well the normal procedure is to have the set_primary_key in place.

If you get the add/edit forms but when you click save nothing happens this means that some fields are either empty (you made them as NOT NULL in the database) or have incorrect values.

Also make sure that all fields that are declared as NOT NULL in the db are also declared with the add / edit_fields functions.