Custom Add, Edit and Delete Operations?
- Single Page
Posted 08 December 2011 - 11:45 AM
TIA
Posted 08 December 2011 - 19:44 PM
Know there must be a simple solution to the problem I am faced with, want to know how can I completely replace the operations performed when an Add, Edit or Delete button is pressed?
TIA
[/quote]
For now the only way to do it is to use getState method. You can see it at http://www.grocerycrud.com/crud/function_name/getState .
Posted 08 December 2011 - 19:56 PM
For now the only way to do it is to use getState method. You can see it at http://www.grocerycr...n_name/getState .
[/quote]
You mean after having checked the state, we can just add our own code to do the things .. like for delete action I just want to set the Active Column to a ZERO value .. and that is it.
Posted 08 December 2011 - 20:02 PM
You mean after having checked the state, we can just add our own code to do the things .. like for delete action I just want to set the Active Column to a ZERO value .. and that is it.
[/quote]
For this you can use simply callbacks. For example in your case you can use callback_escape_delete http://www.grocerycr...k_escape_delete . So it escapes the auto delete and you can add your own.You can see an example of a callback at http://www.grocerycr...k_before_insert For now I still don't have an example for the delete. Just remember that to the callback function that you will create you will have the primary key value.
The are plenty functions of callbacks that you can see here: http://www.grocerycrud.com/crud/view/options_functions
Posted 08 December 2011 - 20:09 PM
Posted 09 December 2011 - 06:54 AM
A short example will be greatly appreciated.
Thank you for your time!
1 more thing i forgot to mention, is there anyway to debug the callback functions , because a simple print_r and die doesn't really work. So i guess many people are like me , they don't know what they are working on and is it working at all with the callbacks.
Posted 10 December 2011 - 12:39 PM
I'm sorry to bump you up - but I have a thread on the delete callback - asking for a simple example , and you seem to have missed it ... (5 days in a row) if it's not a big problem , can you just explain how can we get the primary key value to the callback function that we create, and when we are talking about a _n_n relational row - which primary key is sent ?
A short example will be greatly appreciated.
Thank you for your time!
1 more thing i forgot to mention, is there anyway to debug the callback functions , because a simple print_r and die doesn't really work. So i guess many people are like me , they don't know what they are working on and is it working at all with the callbacks.
[/quote]
The only thing that you can do to take the primary key of the insert is to use the callback_after_insert . So the callback that you will have to use this will have two parameters. The post_array that includes the n_n relation and the primary_key so you will create a function similar to this:
function exampe_callback_after_insert($post_array, $primary_key)
{
.....
}
I know that my documentation is really pure for the most of callbacks and it's good that user's understand them even without the documentation that's good ;-) . Of course I try to do my best to have documentation of the most used callbacks.
Now for the second question. I know it's really annoying to don't have a debug mode for the callbacks, and it's really annoying even for me to don't I have an option. I actually use the log_message of codeigniter to test if something works fine. It's not the best solution I know but it's better to use this kind of function than print_r() and die(). The most of calls are ajax calls and there is a problem with debugging. So a temporary solution may be to use the log_message
Posted 07 June 2012 - 15:36 PM
$crud->unset_edit();
$crud->add_action('Edit', 'URL_TO_ICON.png', array($this,'SOME_FUNCTION'));
Hope this helps someone.