Ńņ (üūGc@sSdZddklZd d„Zd d d„Zd d d„ZdddgZd S( s Form Options Helpers i’’’’(t html_escapecCst|dƒo|iƒ}|iƒnt|ttfƒp |f}ng}x„|D]}t|ttfƒo(|\}}t|ƒ}t|ƒ}n|}}t|ƒ}}||jo|id||fƒqZ|id||fƒqZWdi|ƒS(s Create select options from a container (list, tuple, dict). Accepts a container (list, tuple, dict) and returns a string of option tags. Given a container where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and the "firsts" as option text. Dicts are turned into this form automatically, so the keys become "firsts" and values become lasts. If ``selected`` is specified, the matching "last" or element will get the selected option-tag. ``Selected`` may also be an array of values to be selected when using a multiple select. Examples (call, result):: >>> options_for_select([["Dollar", "$"], ["Kroner", "DKK"]]) '\n' >>> options_for_select([ "VISA", "MasterCard" ], "MasterCard") '\n' >>> options_for_select(dict(Basic="$20", Plus="$40"), "$40") '\n' >>> options_for_select([ "VISA", "MasterCard", "Discover" ], ["VISA", "Discover"]) '\n\n' Note: Only the option tags are returned. You have to wrap this call in a regular HTML select tag. tvaluess2ss ( thasattrtitemstsortt isinstancetlistttupleRtappendtjoin(t containertselectedtoptionstelemtnametvaluetntv((sA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pytoptions_for_select s$      csZˆo‡‡fd†}n‡fd†}tg}|D]}|||ƒq:~|ƒS(s Create select options from objects in a container. Returns a string of option tags that have been compiled by iterating over the ``container`` and assigning the the result of a call to the ``value_attr`` as the option value and the ``name_attr`` as the option text. If ``selected`` is specified, the element returning a match on ``value_attr`` will get the selected option tag. NOTE: Only the option tags are returned. You have to wrap this call in a regular HTML select tag. cst|ˆƒt|ˆƒfS(N(tgetattr(R (t value_attrt name_attr(sA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pyt make_elemOscs t|ˆƒS(N(R(R (R(sA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pyRRs(R(R RRR Rt_[1]tx((RRsA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pytoptions_for_select_from_objects>scsZˆo‡‡fd†}n‡fd†}tg}|D]}|||ƒq:~|ƒS(s Create select options from dicts in a container. Returns a string of option tags that have been compiled by iterating over the ``container`` and assigning the result of a call to the ``value_key`` as the option value and the ``name_attr`` as the option text. If ``selected`` is specified, the element returning a match on ``value_key`` will get the selected option tag. NOTE: Only the option tags are returned. You have to wrap this call in a regular HTML select tag. cs|ˆ|ˆfS(N((R (tname_keyt value_key(sA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pyRhscs|ˆS(N((R (R(sA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pyRks(R(R RRR RRR((RRsA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pytoptions_for_select_from_dictsWsRRRN(t__doc__twebhelpers.utilRtNoneRRRt__all__(((sA/usr/lib/python2.6/site-packages/webhelpers/rails/form_options.pyts  5