⚠ 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 is an archived forum. ⚠

  •     

profile picture

Add value to dropdown and refresh (set_relation)



Charles A.
  • profile picture
  • Member

Posted 01 June 2013 - 19:28 PM

Hi, I'm new around here... Can anybody help me on this?
Given this scenario for example:
 
USERS table (id, username, id_country)... 
COUNTRY table (id_country, countryname)
 
and a piece of the controller...
 
$crud = new grocery_CRUD();
$crud->set_table('users');
$crud->set_relation('id_country','country','countryname');
 
Right now, everything works OK... But I'd like to know when I edit/add a USER, and Grocery Crud populates the country dropdown .. is there any way that if the value is not present in the dropdown, I can add the new value inside the same form and refresh the dropdown?? In other words, I add a new user, and expand the country dropdown and the item FRANCE is not present in the list... What I want to do is to write FRANCE in there and refresh ONLY the country dropdown , but now including FRANCE (because "france" value was inserted in country table in the database), all in the same screen I add the country and save the user... Hope somebody give me a hand on this!
Thanks
Charles

Charles A.
  • profile picture
  • Member

Posted 01 June 2013 - 20:32 PM

I guess it's something similar to this:

/topic/364-answered-set-relation-and-add-new-button-to-quick-insert/


davidoster
  • profile picture
  • Member

Posted 01 June 2013 - 23:24 PM

Hello and welcome to the forums [member=Charles A.].

Try ti impelement this code [/topic/364-answered-set-relation-and-add-new-button-to-quick-insert/#entry1458 , /topic/364-answered-set-relation-and-add-new-button-to-quick-insert/#entry5428] and see how it goes.


Charles A.
  • profile picture
  • Member

Posted 02 June 2013 - 00:01 AM

Thanks David! I'm checking the posts!