I'm just beginning to study cakephp to build web applications and I have very limited knowledge at now.
I am following an example of a book, consisting of a login page to connect. I build models, controller and MySQL connection already, and now i'm with the view 'login.ctp'
This is mi code for login.ctp is just this:
<h1>Login de Usuario</h1>
<?php echo $form->create(array('action' => 'login')); ?>
<?php echo $form->input('usuario'); ?>
<?php echo $form->password('pass'); ?>
<?php echo $form->submit(); ?>
</form>
(Also in UsuariosController I have function login())
class UsuariosController extends AppController {
var $name = "Usuarios";
var $scaffold;
var $helpers = array ('Form');
function login(){...}
}
but, when I go to localhost/cakephp/usuarios/login, show this error:
Error: Call to a member function create() on a non-object
File: C:\xampp\htdocs\cakephp\app\View\Usuarios\login.ctp
Line: 2
I don't understand this, have I to declare $form in another side? (doesnt work either with '$this->$form->create...') I do not know what to do :/
Thank you in advance for your time.
EDIT:
from what I've read, the variable $ form can be used directly to create forms, so I say I do not understand and if I have to declare somewhere
for example (http://book.cakephp.org/1.3/es/The-Manual/Core-Helpers/Form.html) :
<?php echo $form->create(); ?>
<?php
echo $form->input('username'); //text
echo $form->input('password'); //password
echo $form->input('approved'); //day, month, year, hour, minute, meridian
echo $form->input('quote'); //textarea
?>
<?php echo $form->end('Add'); ?>