This seems simple and I think I know the answer but I've searched and can't find anything to back up my assumption.
Many CakePHP code samples use the following syntax:
开发者_StackOverflow中文版echo $form->inputs();
When I write Cake views using 1.3 or 2.0-RC1, the above syntax does not work but the following does:
echo $this->Form->inputs();
Is $form
simply a deprecated syntax from an old version? Or is it a community-accepted shorthand for abbreviating the longer $this->Form
version? (Or something else?)
I noticed that myself before. By taking a look into the CakePHP-books for versions 1.2 and 1.3 it turns out, that they use $form up to version 1.2 and $this->Form since version 1.3. So $form seems to be deprecated now.
Version 1.2: http://book.cakephp.org/view/183/Creating-Forms
Version 1.3: http://book.cakephp.org/view/1384/Creating-Forms
EDIT:
For further explanation see: Cakephp Helpers in Views and $this
$form is deprecated syntax for 1.3. It's used in cakephp 1.2
If you are using cakephp version 1.2, you'll need $form. Otherwise, when you are using cakephp 1.3 you'll need $this->Form
精彩评论