0

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'); ?>
carlosdiazp
  • 195
  • 1
  • 2
  • 17
  • 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 (I edit in question) – carlosdiazp Jul 10 '13 at 09:21
  • 1
    Please compare the spanish documentation with the english http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/Form.html `$this->Form->create()` btw, is it correct that you're using 1.3 branch? – Honk der Hase Jul 10 '13 at 09:50
  • you are right, im using cakephp 2.3.6 and for that this is the correct http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html and for that now I write this way : Form->create('Recipe'); ?> and it works!!! thank you VERY much @LarsStegelitz – carlosdiazp Jul 10 '13 at 10:15

0 Answers0