add_fields and callback_add_field design problem
- Single Page
Posted 07 March 2012 - 11:01 AM
I need to see different fields when I'm in add or in edit, so I have
$crud->add_fields('my_id');
Also, to choose "my_id" I have a custom select, so I have
$crud->callback_add_field('my_id', array($this, 'my_select'));
$crud->callback_edit_field('my_id', array($this, 'my_select'));
And my callback function, to test
function my_select($value)
{
$input = "<select name='my_id' id='' class='chosen-select' data-placeholder='Select ...'>";
$input .= "<option value=''></option>";
$input .= "<option value=''>Hello</option>";
$input .= "</select>";
return $input;
}
In edit everything is ok
[attachment=62:2012-03-07_115503.jpg]
But see what happens in add
[attachment=63:2012-03-07_115552.jpg]
If I don't use the $crud->add_fields('my_id'); everything is all right.
Posted 07 March 2012 - 18:55 PM
function my_select($value = null) //The only change I did is this line
{
$input = "<select name='my_id' id='' class='chosen-select' data-placeholder='Select ...'>";
$input .= "<option value=''></option>";
$input .= "<option value=''>Hello</option>";
$input .= "</select>";
return $input;
}
and probably it will work. At the callback_add_field I don't pass any parameter so it cause for sure an error there that the parameter is not found.
P.S. Really thank you to give so good example for your problem. Perfect description . You have all the code that causes the problem and not for example all the controller and a print-screen
Posted 08 March 2012 - 09:47 AM
If I have only the function
$crud->callback_add_field('my_id', array($this, 'my_select'))
with, of course, the function definition
function my_select($value = null)...
everything is all right.
But if I have also the function
$crud->add_fields('my_id');
it's when the design is not correct.
I realised that happens as well with the edit.
If I have only the function
$crud->callback_edit_field('my_id', array($this, 'my_select'))
it's ok, but the design is not ok if I have also the function
$crud->edit_fields('my_id');
Any other idea?
Posted 08 March 2012 - 22:04 PM
$crud->set_css('assets/grocery_crud/css/jquery_plugins/chosen/chosen.css');
$crud->set_js('assets/grocery_crud/js/jquery_plugins/jquery.chosen.min.js');
$crud->set_js('assets/grocery_crud/js/jquery_plugins/config/jquery.chosen.config.js');
Posted 09 March 2012 - 08:44 AM
I tried it already, and I'm afraid it's not working neither. It's a weird bug, isn't it? If you have any other idea, I'll appreciate it.
Thanks Johnny.
Posted 09 March 2012 - 19:06 PM
Thank you
Posted 12 March 2012 - 09:32 AM
Actually I can't, because I decided to change this part of my application and to use a temporary table instead of a custom select. So, I don't need the callback.
Thanks any way for the feedback.