Re: drop down not keeping value after errors are shown

Mike Garey
2008-03-03T22:59:24Z

have you tried logging the value of @my_obj.card_type to see what it returns?

Mike

On 3/3/08, Jimmy Palmer
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
>
>  My drop down gets reset to the first value when the form gets returned
>  with errors.
>
>  here is my code:
>
>  <%= f.select :card_type,  [
>   [''Choose a Payment Type'', nil],
>   [''Visa'', ''Visa''],
>   [''MasterCard'', ''master''],
>   [''American Express'', ''American
Express'']] %>
>
>  For example, say the user selects "Visa" and doesn''t
fill out the rest
>  of the form correctly.  The user submits the form and errors are shown.
>  For some reason this drop down does not keep the "Visa" value
and goes
>  back to the "Choose a Payment Type".
>
>  How can i keep the value in the drop down after errors are shown?
>  --
>  Posted via http://www.ruby-forum.com/.
>
>  >