<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Populating a SELECT box with distinct values</title>
	<atom:link href="http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/</link>
	<description>Petr 'PePa' Pavel</description>
	<lastBuildDate>Tue, 06 Jul 2010 18:19:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: CyberCortex</title>
		<link>http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/#comment-6360</link>
		<dc:creator>CyberCortex</dc:creator>
		<pubDate>Mon, 07 Dec 2009 23:56:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pepa.info/?p=90#comment-6360</guid>
		<description>After a lot of tests, I finally solved this problem with this ridiculous line:

$years = $this-&gt;Payments-&gt;find(&#039;list&#039;, array(&#039;fields&#039; =&gt; array(&#039;year&#039;, &#039;year&#039;)));

Sorry for my bad english, I am Brazilian.</description>
		<content:encoded><![CDATA[<p>After a lot of tests, I finally solved this problem with this ridiculous line:</p>
<p>$years = $this-&gt;Payments-&gt;find(&#8216;list&#8217;, array(&#8216;fields&#8217; =&gt; array(&#8216;year&#8217;, &#8216;year&#8217;)));</p>
<p>Sorry for my bad english, I am Brazilian.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petr 'PePa' Pavel</title>
		<link>http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/#comment-4556</link>
		<dc:creator>Petr 'PePa' Pavel</dc:creator>
		<pubDate>Fri, 25 Sep 2009 09:07:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pepa.info/?p=90#comment-4556</guid>
		<description>Ming, your code wouldn&#039;t work for several reasons:
&lt;ol&gt;
	&lt;li&gt;If you just return something then you can&#039;t use it in your view to populate SELECT box. Maybe you omitted $this-&gt;set() just to keep your code simple though.&lt;/li&gt;

	&lt;li&gt;With $this-&gt;set() your solution would pass through
array(0 =&gt; value1, 1 =&gt; value2 ...)
and thus if I choose value1 in the SELECT box it&#039;s in fact &quot;0&quot; that gets submitted.
We need
array(value1 =&gt; value1, value2 =&gt; value2 ...)
because we want value1 submitted.&lt;/li&gt;

	&lt;li&gt;I also considered that you were in fact, just suggesting to use find(&#039;list). But then again you get
array(0 =&gt; value1, 1 =&gt; value2 ...)
&lt;/li&gt;
&lt;/ol&gt;

But thanks for commenting. Expressing opinions, making suggestions. That&#039;s what these comments are for.</description>
		<content:encoded><![CDATA[<p>Ming, your code wouldn&#8217;t work for several reasons:</p>
<ol>
<li>If you just return something then you can&#8217;t use it in your view to populate SELECT box. Maybe you omitted $this->set() just to keep your code simple though.</li>
<li>With $this->set() your solution would pass through<br />
array(0 => value1, 1 => value2 &#8230;)<br />
and thus if I choose value1 in the SELECT box it&#8217;s in fact &#8220;0&#8243; that gets submitted.<br />
We need<br />
array(value1 => value1, value2 => value2 &#8230;)<br />
because we want value1 submitted.</li>
<li>I also considered that you were in fact, just suggesting to use find(&#8216;list). But then again you get<br />
array(0 => value1, 1 => value2 &#8230;)
</li>
</ol>
<p>But thanks for commenting. Expressing opinions, making suggestions. That&#8217;s what these comments are for.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ming</title>
		<link>http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/#comment-4554</link>
		<dc:creator>Ming</dc:creator>
		<pubDate>Fri, 25 Sep 2009 07:34:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pepa.info/?p=90#comment-4554</guid>
		<description>How about this...

$list = $this-&gt;find(&#039;list&#039;, array(&#039;fields&#039; =&gt; array(&#039;Model.field&#039;)));
return array_unique($list);</description>
		<content:encoded><![CDATA[<p>How about this&#8230;</p>
<p>$list = $this-&gt;find(&#8216;list&#8217;, array(&#8216;fields&#8217; =&gt; array(&#8216;Model.field&#8217;)));<br />
return array_unique($list);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petr 'PePa' Pavel</title>
		<link>http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/#comment-2024</link>
		<dc:creator>Petr 'PePa' Pavel</dc:creator>
		<pubDate>Fri, 16 Jan 2009 12:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pepa.info/?p=90#comment-2024</guid>
		<description>Hi Steve, that&#039;s weird that you&#039;re getting an error. 
I&#039;m using CakePHP 1.2.0.7692 RC3 and my real code differs from the example I have given in my post only in that I specify additional options like &quot;order&quot; and &quot;recursive&quot; for the find() call.

My best guess is that your find call doesn&#039;t return a valid search result array (e.g. because of a typo in a field name), or you changed the variable name that holds it but forgot to change it later in the combine call as well. I create this kind of errors all the time.

Petr</description>
		<content:encoded><![CDATA[<p>Hi Steve, that&#8217;s weird that you&#8217;re getting an error.<br />
I&#8217;m using CakePHP 1.2.0.7692 RC3 and my real code differs from the example I have given in my post only in that I specify additional options like &#8220;order&#8221; and &#8220;recursive&#8221; for the find() call.</p>
<p>My best guess is that your find call doesn&#8217;t return a valid search result array (e.g. because of a typo in a field name), or you changed the variable name that holds it but forgot to change it later in the combine call as well. I create this kind of errors all the time.</p>
<p>Petr</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SteveH</title>
		<link>http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/#comment-2022</link>
		<dc:creator>SteveH</dc:creator>
		<pubDate>Fri, 16 Jan 2009 03:54:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.pepa.info/?p=90#comment-2022</guid>
		<description>Ok,

I&#039;m still perplexed with simply populating a SELECT box with distinct values from a table column.

Something like:

$this-&gt;set(&#039;citylist&#039;, $this-&gt;Zldinput-&gt;find(&#039;list&#039;, array(&#039;fields&#039;=&gt;&#039;Zldinput.City&#039;, &#039;group&#039;=&gt;&#039;Zldinput.City&#039;)));

gets me close, but as you mention  my array has elements of the id and City thus my SELECT gets

BOSTON

where I want the ......value=&quot;BOSTON&quot;&gt;BOSTON.

your solution is close but combine throws an error on $events

Cheers, Steve</description>
		<content:encoded><![CDATA[<p>Ok,</p>
<p>I&#8217;m still perplexed with simply populating a SELECT box with distinct values from a table column.</p>
<p>Something like:</p>
<p>$this-&gt;set(&#8216;citylist&#8217;, $this-&gt;Zldinput-&gt;find(&#8216;list&#8217;, array(&#8216;fields&#8217;=&gt;&#8217;Zldinput.City&#8217;, &#8216;group&#8217;=&gt;&#8217;Zldinput.City&#8217;)));</p>
<p>gets me close, but as you mention  my array has elements of the id and City thus my SELECT gets</p>
<p>BOSTON</p>
<p>where I want the &#8230;&#8230;value=&#8221;BOSTON&#8221;&gt;BOSTON.</p>
<p>your solution is close but combine throws an error on $events</p>
<p>Cheers, Steve</p>
]]></content:encoded>
	</item>
</channel>
</rss>
