# Is there a list of html\_options for the FormOptionsHelper?

**URL:** <https://www.ruby-forum.com/t/is-there-a-list-of-html-options-for-the-formoptionshelper/50612>\
**Category:** Rails\
**Created:** [December 19, 2005, 4:30am UTC](https://www.ruby-forum.com/t/is-there-a-list-of-html-options-for-the-formoptionshelper/50612 "2005-12-19T04:30:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![corny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@corny](https://www.ruby-forum.com/u/corny)\
**Post date:** [December 19, 2005, 4:30am UTC](https://www.ruby-forum.com/t/is-there-a-list-of-html-options-for-the-formoptionshelper/50612/1 "2005-12-19T04:30:59Z")

</div>

I’m looking for a way to select a default value from a select box, like  
this:

select(“user”, “role\_id”, Role.find\_all.collect {|r| [r.name, r.id] },  
{ :default\_value =\> ‘5’ }

(of course, there is no “:default\_value”)

If the form is being used on a ‘create’ page, it should display a  
default in the select box. If the form is on the ‘edit’ page, it should  
display the current value.

Thanks,  
corny

(2nd day on Rails, 1st post to the forum)

---

<div class="post-metadata">

**Author:** ![corny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@corny](https://www.ruby-forum.com/u/corny)\
**Post date:** [December 19, 2005, 4:48am UTC](https://www.ruby-forum.com/t/is-there-a-list-of-html-options-for-the-formoptionshelper/50612/2 "2005-12-19T04:48:06Z")

</div>

On 12/18/05, Cornelius B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> display the current value.  
> Assuming I’m understanding your question correctly, this should be  
> handled automatically by the #select method. According to the API  
> documentation [1]:

```
The option currently held by the object will be selected, provided 

```

that  
the object is available.

[1]  
[http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000351](http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000351)

–  
Regards,  
John W.

> **[John Wilger](http://johnwilger.com)**
>
> The personal website of John Wilger; Dad, Cyclist, Software Developer

* * *

Alice came to a fork in the road. “Which road do I take?” she asked.  
“Where do you want to go?” responded the Cheshire cat.  
“I don’t know,” Alice answered.  
“Then,” said the cat, “it doesn’t matter.”

- Lewis Carrol, Alice in Wonderland

---

<div class="post-metadata">

**Author:** ![corny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@corny](https://www.ruby-forum.com/u/corny)\
**Post date:** [December 19, 2005, 4:51am UTC](https://www.ruby-forum.com/t/is-there-a-list-of-html-options-for-the-formoptionshelper/50612/3 "2005-12-19T04:51:07Z")

</div>

On 12/18/05, Cornelius B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> display the current value.  
> html\_options are for attributes, like class.

select is one of the form helpers that uses ActiveRecord. The default  
value is therefore whatever @user.role\_id is. You should be able to  
set it in the controller.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![corny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@corny](https://www.ruby-forum.com/u/corny)\
**Post date:** [December 19, 2005, 6:11am UTC](https://www.ruby-forum.com/t/is-there-a-list-of-html-options-for-the-formoptionshelper/50612/4 "2005-12-19T06:11:48Z")

</div>

Thanks Rick, that did it!

John, if the object is NOT available I wanted to display a default  
option.

In the ‘Account/signup’ controller, I put:

@user = User.new(@params[:user])  
@roles = Role.find\_all  
@user.role\_id = ‘5’
