⚠ 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

Set value on add_action



Dhan Pra Setya
  • profile picture
  • Member

Posted 15 June 2015 - 10:35 AM

Hi, I want to know if ADD ACTION can set/change value on certain columns in my case, I want to set 'publish' column from 'article' table which has value 1 for public, 0 for private. I have idea to use callback, but I haven't know which one. Any idea? Thanks in advance!


Paul Savostin
  • profile picture
  • Member

Posted 15 June 2015 - 20:57 PM

So what is the problem?

Correct me if I am wrong:

You have each row with ADD_ACTION button, while clicking on it you need change some field of this row in database, for example set 0 or if it already 0 set to 1, right?

If so - create method in you controller for this ADD_ACTION where you get PRIMARY KEY of current row, then request to database to get this row interested you field, check it - if 0 then you should set 1, otherwise set 0.

After just redirect to the list (mean method where you adding add_action to the Grocery Crud).


aron2020
  • profile picture
  • Member

Posted 22 November 2015 - 21:37 PM

Paul,

 

"You have each row with ADD_ACTION button, while clicking on it you need change some field of this row in database, for example set 0 or if it already 0 set to 1, right?"

 

that is exactly what I need to do; i am new to grocery crud, can you give me a few lines about this method...  

how to get request to DB?

how to write back new value?

how to redisplay the grid?

 

thanks,

aron


Paul Savostin
  • profile picture
  • Member

Posted 23 November 2015 - 16:31 PM

LOL, sorry I cant post here simple staff about requesting DB, this is what u need to invistigate by yourself ;)