I found very nice php api last week, Grocery Crud, from examples available here http://www.grocerycrud.com/examples/the-simplest-example , I could create view and its working fine, my question is there are 2 buttons once you edit Update Changes and Update Back to List, I am interested to print post array whenever I click these two button, so that I can see what is inside array, and my actual plan is whenever I update record ( on click of update changes or update and back to list in edit ), I need to update about 7 tables
Here is what I have tried so far, here function test prints nothing
function test($post_array)
{
echo "<pre>";
print_r($post_array);
echo "</pre>";
}
function myapp(){
$this->db = $this->load->database('Groupdb',true);
$crud = new grocery_CRUD();
$crud->set_table('main_table');
$crud->columns(
"Serial",
"Date",
"Time"
);
$crud->fields(
"Serial",
"Date",
"Time"
);
$crud->callback_after_update(array($this, 'test'));
$crud->set_subject('Update Mains');
$output = $crud->render();
$this->_example_output($output);
}
From my code I think you guys can imagine table name is main_table, whenever I update serial, date and time, of main_table, it has to be reflected on 7 other tables whose fields are date and time, here serial number is unique
First of all if you are using PHP >= 5.3 then it is better to use anonymous functions just to be more sure that it will work. So for example, at your code you can have:
$crud->callback_after_update(function () {
echo "<pre>";
print_r($post_array);
echo "</pre>";
die();
});
As you've noticed I did add one more line there. This is the die();. With this way, you can make sure that you will see the expected results at your firebug.
Probably you didn't have any print because grocery CRUD is removing anything that it was printed before with some magic code . With the die(); you are just making sure that this magic code is never reached.
This question is already answered at: Debugging in Grocery CRUD
More specifically:
Still grocery CRUD doesn't support debugging for callbacks so I think its a good solution for now. Beside this for debugging without hacking you can always easily have the log_message function of codeigniter. For more you can see at http://ellislab.com/codeigniter/user-guide/general/errors.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With