I will try that, thank you very much :)
So now I have to do in the library, I can not do it on the same controller (more dynamic and customizable)
[updated 24/11/2012] Dependent dropdown (library)
Posted 15 March 2013 - 22:20 PM
Posted 15 March 2013 - 22:25 PM
try to do it
Posted 15 March 2013 - 22:50 PM
I added this: ('where' => 'country_id = '13' ") in the first field (country)
I put the country_id = 13 directly to test, and it did not work. :wacko:
Posted 15 March 2013 - 22:53 PM
draw a scheme of your tables
Posted 15 March 2013 - 22:54 PM
and explain in more detail how it must works
Posted 15 March 2013 - 23:10 PM
My schedule is very large, complex and is in Spanish, but basically is the same as your example. But what I want to achieve is that when you add or edit a record in the table (dd_goods), the selectbox (goods_country) only shows the country of the user who is using the system. Currently showing all countries: (
I think the solution is around the code you gave me
Posted 16 March 2013 - 07:40 AM
Hi Victor,
Please see my message before...any idea?
Posted 16 March 2013 - 11:54 AM
Posted 16 March 2013 - 21:43 PM
Victor, in the controller (dd_goods) i did a callback_field for the parent selectbox:
$crud->callback_field ( 'country_id', array ( $this, '_callback_1' ) );
and it works, but can pass parameters to a this callback? to do dynamic
function _callback_1($value = '', $primary_key = null)
{
$this->db->select ( '*' );
$this->db->from ( 'dd_country' );
$this->db->where ( 'country_id', '13' ); // 13 is a id for test
$result = $this->db->get ();
$data = $result->row ();
$html = '<select name="country_id" class="chosen-select" data-placeholder="Select Country" style="width: 200px;">';
$html.= '<option value=""></option>';
$html.= '<option value="'.$data->country_id.'" >'.$data->country_title.'</option>';
$html.= '</select>';
return $html;
}
Note: I'm trying to filter the parent dropdown
Posted 16 March 2013 - 22:39 PM
If you want to change the parent dropdown you can use callback function as you like. The library doesn't touches to the parent dropdown.
For example you can use callback_add_field and callback_edit_field for the first doropdown of this system
Posted 16 March 2013 - 23:06 PM
ok, thanks
I think I will use the callback_field for this.
any idea how to pass data as parameters to the callback_field function? , is that I use this function a lot, thanks again.
Posted 17 March 2013 - 02:56 AM
Posted 17 March 2013 - 09:08 AM
Posted 17 March 2013 - 09:08 AM
Posted 28 March 2013 - 04:43 AM
Any idea Victor? I sent the database dump by private message. MY problem is stated in message #176.
Posted 28 March 2013 - 21:06 PM
Hi, guys! I'm sorry. I have no time at all to help you in this week. I have too much work. Very much...
I have a heavy time now :wacko:
I am very tired every day.
Posted 31 March 2013 - 00:59 AM
Hi,
I tried to use your library
I used the code from your example data located on the first page and got an error:
Error Number: 1064
You have an error in your SQL syntax:
SELECT dd_country., dd_country.country_title as se3dbd3a3 FROM (`dd_country`) ORDER BY `se3dbd3a3`
I also tried to use callback_add_field for the first dropdown field. It helps and the add page is loading but there is no first dropdown in the form.
Is there a bug in the example or am I doing something wrong?
Posted 31 March 2013 - 20:59 PM
Can you show your code where you get this error?
Posted 04 April 2013 - 21:21 PM
Thanks.
Just managed to solve the problem.
Posted 09 April 2013 - 22:17 PM
I have a few days to answer on your querstions.