<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - How to give an ID to an input when using select helpers?]]></title>
	<link rel="self" href="http://railsforum.com/extern.php?action=feed&amp;tid=147&amp;type=atom"/>
	<updated>2006-07-30T20:28:57Z</updated>
	<generator>PunBB</generator>
	<id>http://railsforum.com/viewtopic.php?id=147</id>
		<entry>
			<title type="html"><![CDATA[Re: How to give an ID to an input when using select helpers?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=1359#p1359"/>
			<content type="html"><![CDATA[<p>Most ActionView helpers include an id of the form &quot;#{object}_#{method}&quot;.&nbsp; In situations like radio buttons where there needs to be slightly more information in the id there&#039;s another underscore and then the value of the radio button.&nbsp; Does anyone know why these select fields don&#039;t default to an id of the same format?</p><p>Yeah, this should definitely be made into a patch.&nbsp; The Rails team prefers that you just submit a test to test this functionality and let them add the actual code - anybody up to the challenge?</p>]]></content>
			<author>
				<name><![CDATA[danger]]></name>
				<uri>http://railsforum.com/profile.php?id=56</uri>
			</author>
			<updated>2006-07-30T20:28:57Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=1359#p1359</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to give an ID to an input when using select helpers?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=942#p942"/>
			<content type="html"><![CDATA[<p>Thanks for the reply, I had a feeling it may not be possible since its not in the API docs.<br />I need the ID to be on the actual input tag because I need to change its value using javascript.<br />I could either try the hack or just make some partials with the helper generated html in them, adding the IDs of course...</p><br /><p>I guess if I have time the best thing to do would be to upgrade the helpers to include this functionality and submit it back to the Rails project for inclusion.</p><p>AFM <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[afm]]></name>
				<uri>http://railsforum.com/profile.php?id=102</uri>
			</author>
			<updated>2006-07-11T10:45:46Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=942#p942</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to give an ID to an input when using select helpers?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=812#p812"/>
			<content type="html"><![CDATA[<p>Sorry this isn&#039;t very helpful, but I don&#039;t think it&#039;s possible. Date selectors in rails don&#039;t seem to offer a whole lot in the customization department. You can try wrapping each select in a span with an id and try to get to the select that way (depending upon how you were going to use the &quot;id&quot; attribute).</p><p><pre name="code" class="ruby:nogutter">&lt;span id=&quot;day_field&quot;&gt;<br />&nbsp; &lt;%= select_day(Date.today, :prefix =&gt; &#039;search[date]&#039;) %&gt;<br />&lt;/span&gt;<br />&lt;span id=&quot;month_field&quot;&gt;<br />&nbsp; &lt;%= select_month(Date.today, :prefix =&gt; &#039;search[date]&#039;) %&gt;<br />&lt;/span&gt;</pre><br />The only other option I see is building your own date selector.</p><p>[edit]<br />Okay, I take that back. It is <em>possible</em> but with an <strong>EXTREMELY ugly</strong> hack.</p><p><pre name="code" class="ruby:nogutter">&lt;%= select_day(Date.today, :prefix =&gt; &#039;search[date][day]&quot; id=&quot;day_field&#039;, :discard_type =&gt; true) %&gt;<br />&lt;%= select_month(Date.today, :prefix =&gt; &#039;search[date][month]&quot; id=&quot;month_field&#039;, :discard_type =&gt; true) %&gt;</pre><br />That is a really bad hack and I don&#039;t even recommend it (it may very well break in a future rails version). I just wanted to show it is possible. <img src="http://railsforum.com/img/smilies/wink.png" width="15" height="15" alt="wink" /><br />[/edit]</p>]]></content>
			<author>
				<name><![CDATA[ryanb]]></name>
				<uri>http://railsforum.com/profile.php?id=52</uri>
			</author>
			<updated>2006-07-05T18:36:37Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=812#p812</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to give an ID to an input when using select helpers?]]></title>
			<link rel="alternate" href="http://railsforum.com/viewtopic.php?pid=805#p805"/>
			<content type="html"><![CDATA[<p>If I&#039;m using a date_select helper how can I tell the helper to add an ID to the select, the name of the element is set (to model[attribute]) of course, but I cant find how to add an ID.</p><p><pre name="code" class="ruby:nogutter">&lt;%= date_select(&quot;search&quot;, &quot;date&quot;, :discard_year =&gt; true, :order =&gt; [:day, :month]) %&gt;</pre><br />It does not seem to appear in the Rails API...</p><p><pre name="code" class="ruby:nogutter">&lt;select name=&quot;search[date][day]&quot;&gt;<br />&nbsp; &lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;<br />&nbsp; &nbsp; &lt;snip&gt;<br />&nbsp; &lt;option value=&quot;31&quot;&gt;31&lt;/option&gt;<br />&lt;/select&gt;</p><p>&lt;select name=&quot;search[date][month]&quot;&gt;<br />&nbsp; &lt;option value=&quot;1&quot;&gt;January&lt;/option&gt;<br />&nbsp; &nbsp; &lt;snip&gt;<br />&nbsp; &lt;option value=&quot;12&quot;&gt;December&lt;/option&gt;<br />&lt;/select&gt;</pre></p>]]></content>
			<author>
				<name><![CDATA[afm]]></name>
				<uri>http://railsforum.com/profile.php?id=102</uri>
			</author>
			<updated>2006-07-05T15:24:29Z</updated>
			<id>http://railsforum.com/viewtopic.php?pid=805#p805</id>
		</entry>
</feed>
