Jump to content


Add value to dropdown and refresh (set_relation)

ajax dropdown set_relation refresh form form edit

  • Please log in to reply
3 replies to this topic

#1 Charles A.

Charles A.

    Member

  • Members
  • PipPip
  • 17 posts

Posted 01 June 2013 - 07: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


#2 Charles A.

Charles A.

    Member

  • Members
  • PipPip
  • 17 posts

Posted 01 June 2013 - 08:32 PM

I guess it's something similar to this:

http://www.grocerycr...o-quick-insert/



#3 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 01 June 2013 - 11:24 PM

Hello and welcome to the forums Charles A..

Try ti impelement this code [http://www.grocerycr...sert/#entry1458 , http://www.grocerycr...sert/#entry5428] and see how it goes.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#4 Charles A.

Charles A.

    Member

  • Members
  • PipPip
  • 17 posts

Posted 02 June 2013 - 12:01 AM

Thanks David! I'm checking the posts!







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users