# Radio buttons for arrays

**URL:** <https://www.ruby-forum.com/t/radio-buttons-for-arrays/172586>\
**Category:** Rails\
**Created:** [July 23, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/radio-buttons-for-arrays/172586 "2009-07-23T17:39:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [July 23, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/radio-buttons-for-arrays/172586/1 "2009-07-23T17:39:41Z")

</div>

Hi,

Presently I am using drop down with following function  
\<%= task\_form.collection\_select :task\_type,  
@task\_types, :id, :display\_value %\>  
It basically gives me ability to have drop down based on an array of  
objects

I am looking for a similar radio buttons function which will allow me  
to only give it an array and the GUI will render it into radio  
buttons.

Can someone please assist?

---

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [July 23, 2009, 9:38pm UTC](https://www.ruby-forum.com/t/radio-buttons-for-arrays/172586/2 "2009-07-23T21:38:17Z")

</div>

Does anyone know this? please…

---

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [July 24, 2009, 5:00am UTC](https://www.ruby-forum.com/t/radio-buttons-for-arrays/172586/3 "2009-07-24T05:00:08Z")

</div>

On Jul 23, 2009, at 12:37 PM, Ritvvij wrote:

> > objects
> > 
> > I am looking for a similar radio buttons function which will allow me  
> > to only give it an array and the GUI will render it into radio  
> > buttons.
> > 
> > Can someone please assist?

It doesn’t look like anyone’s answered this so far… You’ll have to  
write your own helper to provide this functionality. A place to begin  
your research on how to implement it is in the Rails code itself,  
actionpack/lib/action\_view/helpers/form\_options\_helper.rb, and look at  
how collection\_select is implemented. If you come up with a great  
solution, a plugin, gem or fork or Rails would be great to share it  
back.
