⚠ 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 forum is read-only and soon will be archived. ⚠

Conditional delete/deactivate?

delete conditional list view deactivate

  • Please log in to reply
1 reply to this topic

#1 Kobus


    Advanced Member

  • Members
  • PipPipPip
  • 74 posts

Posted 31 August 2014 - 05:43 PM

Hi all,


Just a quick question, hoping someone has done this before:


1. I have a table called "security_questions" which contains like 20 or so security questions that users can choose when they register on my side.

2. I have used Grocery CRUD for admins to manage the questions.

3. When users choose their security questions on signup, a separate table "user_security_questions" is populated with their question ID and their respective answers.

4. I want to be able to prevent deletion/deactivation of an item that is in use by any user.


Is there a quick way to do this? Anybody done similar things before? I am thinking a callback "before delete" and then check if the ID is in use, then return false if so, but perhaps there is something better, such as not showing the delete icon in the first place in list view?


The alternative to finding a way to delete the item in the "user_security_question" at the time of delete via a callback is not ideal, because in the event of there being only one security question, the user's security question will be deleted.


Any ideas will be appreciated!


Kind regards,




#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 04 September 2014 - 03:52 AM

Hi there - yes you thought in the right direction to use callback before delete - but since you want to control where you want to show the delete button - you may do the following

unset the delete functionality for the crud

add an extra column stating something like user action or whatever suites it

make a callback to the column

there - match the condition for the id - if it is in use - just return blank or return with a buttonized href to delete the element.

You may garnish the solution with javascript hooked to the button class (you may give 1 unique class name to connect to each) on click of which it pops up like actual delete button


Hope this works out


Happy GCing :)

Also tagged with one or more of these keywords: delete, conditional, list view, deactivate

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users