<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>BlaCKReed.com &#187; psa</title>
	<atom:link href="http://blackreed.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blackreed.com</link>
	<description>Ordinary user of CakePHP</description>
	<pubDate>Mon, 28 Apr 2008 03:57:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Using ExtJS form integrated with CakePHP</title>
		<link>http://blackreed.com/2008/04/using-extjs-form-integrated-with-cakephp/</link>
		<comments>http://blackreed.com/2008/04/using-extjs-form-integrated-with-cakephp/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 03:56:47 +0000</pubDate>
		<dc:creator>psa</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<category><![CDATA[ExtJS]]></category>

		<guid isPermaLink="false">http://blackreed.com/?p=5</guid>
		<description><![CDATA[It should be nice when we create form using ExtJS, so we don’t need to create html or css form from the scratch. For the first time I try to create form with ExtJS and data handle with PHP, I mean pure PHP and doesn’t use any framework.
Now, I try to implement an integrated ExtJS [...]]]></description>
			<content:encoded><![CDATA[<p>It should be nice when we create form using ExtJS, so we don’t need to create html or css form from the scratch. For the first time I try to create form with ExtJS and data handle with PHP, I mean pure PHP and doesn’t use any framework.<br />
Now, I try to implement an integrated ExtJS with CakePHP, so it is a little note when I do this experiment.<span id="more-5"></span><br />
This time I’ll wrote simple address book application, I’m using MySQL database for the back-end. here is the SQL code:</p>
<pre class="syntax-highlight:php">

CREATE TABLE `addresses` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`address` text NOT NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;
</pre>
<p>For my convenient I create a new layout for this trial, then<br />
I add the following code between tag head in my layout.</p>
<pre class="syntax-highlight:php">&lt;script src=&quot;http://blackreed.com/js/ext/adapter/ext/ext-base.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://blackreed.com/js/ext/ext-all.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://blackreed.com/js/my/form.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>As usual I always make a model first, and the model for address look like this</p>
<pre class="syntax-highlight:php">
&lt; ?php
class Address extends AppModel
{
var $name = 'Address';
}
?&gt;
</pre>
<p>Now I need to prepare a controller for this application, here is the code</p>
<pre class="syntax-highlight:php">
&lt; ?php
// /app/controllers/addresses_controller.php
class AddressesController extends AppController
{
var $name = 'Addresses';
var $layout = &quot;designaddress&quot;;

function index()
{

}

function add()
{
$this-&gt;layout = &quot;ajax&quot;;

if (!empty($this-&gt;params))
{
$this-&gt;data['Address']['name'] = $this-&gt;params['form']['name'];
$this-&gt;data['Address']['address'] = $this-&gt;params['form']['address'];

$this-&gt;Address-&gt;create();
if ($this-&gt;Address-&gt;save($this-&gt;data))
{
$this-&gt;set('status', '{success:true}');
}
else
{
$this-&gt;set('status', '{success:false}');
}
}
else
{
$this-&gt;set('status', '{success:false}');
}
}
}

?&gt;
</pre>
<p>On this controller, I put method index, this method I prepared to show the form integrated with<br />
ExtJS, on the next view (index.ctp) you can see it. Then I put method add() it is used to save data into database.<br />
Please remember to set no debug in file /app/config/core.php or you can do it inside add method with: Configure::write(’debug’, 0);<br />
Debug message will break ajax.</p>
<p>On the view index.ctp I put the following code :<br />
put in /app/views/addresses/index.ctp</p>
<pre class="syntax-highlight:html">
&lt;div id=&quot;form1&quot;&gt;&lt;/div&gt;
</pre>
<p>In the view I provide container for form generated by ExtJS.</p>
<p>Next the view (add.ctp) provide for add method<br />
put in /app/views/addresses/add.ctp</p>
<pre class="syntax-highlight:php">
&lt; ?php
echo $status;
?&gt;
</pre>
<p>And here is the code for creating form with ExtJS<br />
put in /app/webroot/js/my/form.js</p>
<pre class="syntax-highlight:javascript">
Ext.onReady(function(){
var form1 = new Ext.FormPanel({
url: '/addresses/add',
renderTo: 'form1',
title: 'Form Address',
width: 300,
items: [{
xtype: 'textfield',
fieldLabel: 'Your Name',
name: &quot;name&quot;,
allowBlank: false
},{
xtype: 'textarea',
fieldLabel: 'Address',
name: &quot;address&quot;
}],
buttons: [{
text: 'Save',
handler: function(){
form1.form.submit({
waitMsg: 'Saving...',
success: function() {
Ext.MessageBox.alert('Status','Save done');
},
failure: function() {
Ext.MessageBox.alert('Status','Save failed');
}
});
}
}, {
text: 'Cancel'
}]
});
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blackreed.com/2008/04/using-extjs-form-integrated-with-cakephp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Deprecated generateList in CakePHP 1.2</title>
		<link>http://blackreed.com/2008/04/deprecated-generatelist-in-cakephp-12/</link>
		<comments>http://blackreed.com/2008/04/deprecated-generatelist-in-cakephp-12/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 06:46:44 +0000</pubDate>
		<dc:creator>psa</dc:creator>
		
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://blackreed.com/?p=4</guid>
		<description><![CDATA[I’m trying to use generateList function in CakePHP 1.2 but I got a line of error message that said generateList function was deprecated.
Here is the error message detail
&#60;span&#62;&#60;span&#62;Warning (512): (Model::generateList) Deprecated, &#60;/span&#62;&#60;span class=&#34;keyword&#34;&#62;use&#60;/span&#62;&#60;span&#62; Model::find(&#60;/span&#62;&#60;span class=&#34;string&#34;&#62;&#34;list&#34;&#60;/span&#62;&#60;span&#62;) &#60;/span&#62;&#60;span class=&#34;keyword&#34;&#62;or&#60;/span&#62;&#60;span&#62; Model::find(&#60;/span&#62;&#60;span class=&#34;string&#34;&#62;&#34;all&#34;&#60;/span&#62;&#60;span&#62;) &#60;/span&#62;&#60;span class=&#34;keyword&#34;&#62;and&#60;/span&#62;&#60;span&#62; Set::combine() [CORE\cake\libs\model\model.php, line 2191]  
So I take a look to cake-php mailing list [...]]]></description>
			<content:encoded><![CDATA[<p>I’m trying to use generateList function in CakePHP 1.2 but I got a line of error message that said generateList function was deprecated.<span id="more-4"></span><br />
Here is the error message detail</p>
<pre class="syntax-highlight:php">&lt;span&gt;&lt;span&gt;Warning (512): (Model::generateList) Deprecated, &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;use&lt;/span&gt;&lt;span&gt; Model::find(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;list&quot;&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;or&lt;/span&gt;&lt;span&gt; Model::find(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;all&quot;&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;and&lt;/span&gt;&lt;span&gt; Set::combine() [CORE\cake\libs\model\model.php, line 2191]  </pre>
<p>So I take a look to cake-php mailing list and found a solution that work fine for my need at the time, here is the example code:</p>
<p>In the controller I put line like the following:</p>
<pre class="syntax-highlight:php">// /app/controllers/customers_controller.php
$customers =$this-&gt;Customer-&gt;find(&quot;all&quot;,array('fields'=&gt;array('Customer.customer_name','Customer.id'),'order'=&gt;'Customer.customer_name ASC'));
$cust_combine = Set::combine($customers, '{n}.Customer.id','{n}.Customer.customer_name');
$this-&gt;set('customers', $cust_combine);
</pre>
<p>I want to explain a litte here that you may change fields to suit with your environment,<br />
in above code I put Customer.customer_name and Customer.id because I just need that two field in my form<br />
then in line Set::combine($customers, ‘{n}.Customer.id’,&#8217;{n}.Customer.customer_name’);<br />
I want to make Customer.id as the key and Customer.customer_name as the value.</p>
<p>Here is the code I put in view</p>
<pre class="syntax-highlight:php">// /app/views/customers/index.php
print 'Customer:'. $form-&gt;select('Customer/id', $customers, $html-&gt;Value('Customer/id'), array('class'=&gt;'select large'), array(), true);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blackreed.com/2008/04/deprecated-generatelist-in-cakephp-12/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://blackreed.com/2008/04/hello-world/</link>
		<comments>http://blackreed.com/2008/04/hello-world/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 06:27:49 +0000</pubDate>
		<dc:creator>psa</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blackreed.com/?p=1</guid>
		<description><![CDATA[Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
]]></description>
			<content:encoded><![CDATA[<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
]]></content:encoded>
			<wfw:commentRss>http://blackreed.com/2008/04/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
