How to use forms with CakePHP Framework 2

In this tutorial I will speak about how to use forms with CakePHP Framework 2. In CakePHP Framework 2 is very simple to create and use the forms. In this tutorial I will explain to you how you can create a new form in CakePHP and in my next tutorial I will explain to you how you can save data from form to database.

There is a simple CakePHP's form

echo $this->Form->create();

echo $this->Form->input('username'); //text
echo $this->Form->input('password'); //password
echo $this->Form->input('approved'); //day, month, year, hour, minute,
//meridian
echo $this->Form->input('quote'); //textarea

echo $this->Form->end('Add');

To add GET or POST method, you must add post or get here:

echo $this->Form->create(); // example create('post' or 'get');

To create an email input, you must use this code:

echo $this->Form->input('email', array('type' => 'email'));

To create a file input, you must use this code:

echo $this->Form->input('field', array('type' => 'file'));

Video tutorial:









Leave a Comment