<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - On Form Load combobox item to be selected]]></title>
		<link>http://railsforum.com/viewtopic.php?id=53313</link>
		<description><![CDATA[The most recent posts in On Form Load combobox item to be selected.]]></description>
		<lastBuildDate>Thu, 28 Feb 2013 23:23:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: On Form Load combobox item to be selected]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160759#p160759</link>
			<description><![CDATA[<p>This should work:</p><div class="codebox"><pre><code>&lt;%= select_tag &quot;tenant_cases[]&quot;, options_for_select(Tenant.order.map {|sc| [sc.name, sc.id]}, area.tenant_id),{} %&gt;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (themusicman)]]></author>
			<pubDate>Thu, 28 Feb 2013 23:23:24 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160759#p160759</guid>
		</item>
		<item>
			<title><![CDATA[On Form Load combobox item to be selected]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160274#p160274</link>
			<description><![CDATA[<p>Hello all,</p><p>I have a form where i have numerous labels and Comboboxes based on the number of data in the DB. Below is the code for the same.</p><p>&lt;%= form_tag({:action =&gt; :apply_area, :method =&gt; :get}) do |f| %&gt;</p><p>&nbsp; &nbsp;&lt;% @facility.areas.each do |area| %&gt;<br />&nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%= label_tag &#039;area&#039;, area.name %&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/td&gt;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;&lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div class=&quot;tenant&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%= select_tag &quot;tenant_cases[]&quot;, options_for_select(Tenant.order.map {|sc| [sc.name, sc.id]}),{} %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;/td&gt;&nbsp; &nbsp;</p><p>&nbsp; &nbsp;&lt;% end %&gt;<br />&lt;div class=&quot;actions&quot;&gt;<br />&nbsp; &nbsp; &lt;%= submit_tag (&quot;更新する&quot;) %&gt;<br />&lt;/div&gt;<br />&lt;% end %&gt;</p><p>At present the data gets populated, but my need is something different.</p><p>I have two tables in DB named Tenants and Areas</p><p>Tenants<br />-----------<br />id |&nbsp; facility_id | name | <br />1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Tenant1<br />2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Tenant2</p><p>Areas<br />--------<br />id | facility_id | tenant_id | name |<br />1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Area 1 </p><p>if there is any tenant_id saved in the Areas table then the respective tenant name should be selected in the combobox<br />Eg for Area1 tenant_id is 1 so in the combbox Tenant1 should get selected on the form load.</p><br /><p>Regards,<br />AB</p>]]></description>
			<author><![CDATA[dummy@example.com (abhishekthayyil)]]></author>
			<pubDate>Fri, 22 Feb 2013 04:32:07 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160274#p160274</guid>
		</item>
	</channel>
</rss>
