Getting a drop-down to work in the create/edit form

Skip to first unread message


Apr 6, 2007, 2:17:39 PM4/6/07
to Ruby On Rails: Ajax Scaffold
I want to make one of my fields (I'm using the plugin) a drop-down
list. I've reviewed the posts here, as well as the blog entries on and and I have to admit that
I'm completely confused.

One entry (
ajaxscaffold-3-1-0-released) talks about modifying the _form.rhtml
file and suggests code such as:


&lt;div class="form-element"&gt;
&lt;label for="pet_person"&gt;Owner%lt;/label&gt;
&lt;%= select 'pet', 'owner_id' , Person.find_all.collect {|p|
[, ] } &&gt;


but all I see in my existing _form.rhtml file is:

%lt;div class="row"&rt;
%lt;%= all_input_tags(scaffold_class, scaffold_name, { :exclude =>
%w(created_on created_at updated_on updated_at) }) %&rt;

Does the "form-element" go before the closing fieldset? Or somewhere
else? I've not found this used elsewhere, so I don't have any other
models to study... it can't seem to match what I see in my files with
what people are talking about.

Any help would be much apprciated.



Apr 6, 2007, 5:36:31 PM4/6/07
to Ruby On Rails: Ajax Scaffold
Well... I tried out the example code and all it does it put the "form-
element" stuff at the bottom of the edit box as if it were trying to
set up the field.

I'm guessing that the example code above is for the generator, not for
the plugin... is this right?



Apr 7, 2007, 9:39:26 AM4/7/07
to Ruby On Rails: Ajax Scaffold
OK... I figured out some of it by digging through the AS code. What
started working for me was to:

1. Remove the "all_input_tags" line completely, and
2. Add "form-element" entries for EACH field that I want on the
form... i.e., recreate the form one field at a time

However, I still have a problem in that when the form goes to save the
new/updated record, I get a "field too long" error on the new drop-
down field. Right now, I'm guessing that the form is trying to return
not just the one result but a bunch of other stuff, but I can't tell
right now.

Back to digging...


Apr 7, 2007, 1:19:28 PM4/7/07
to Ruby On Rails: Ajax Scaffold
OK... Pilot error; I figured out how to get the "form-element" to

### This creates the dropdown/select box from the type table...
# Note the doubled t.type_name, required to give the value and the
# display the correct values. There's only text in the type field.
&lt;div class="form-element">
&lt;label for="asset_entry_type">Entry Type&lt;/label>
&lt;%= select 'asset', 'entry_type', Type.find_all.collect { |
t| [ t.type_name, t.type_name ] } %>


Reply all
Reply to author
0 new messages