Reputation: 581
I'm studying CakePHP. I read a CakePHP book, and web tutorials, but I still don't get some basic things:
I see people always create a form in View with $form->create
. Can I use an HTML form like normal, or must do exactly like people do?
When a form is created in login.ctp with this code:
echo $form->create('User', array('method' => 'POST', 'action' => 'login'));
echo $form->input('email');
echo $form->input('password');
echo $form->input(array('type' => 'submit'));
echo $form->end('Login');
When I click the submit button, will the data be passed to the function login()
in the Controller class?
Edited :
I tried this :
<?php
$this->Form->create("Test");
$this->Form->input("stuId",array('class'=>'inputField', 'placeholder'=>'SVxxxxxxxx'));
$this->Form->input("stuName",array('class'=>'inputField', 'name'=>'stuName'));
$this->Form->end();
?>
But it show nothing ? what is the problem :(
Upvotes: 1
Views: 1739
Reputation: 9964
But it show nothing ? what is the problem :(
You have to use echo
as in your first code snippet:
echo $this->Form->create("Test");
echo ...
Upvotes: 3
Reputation: 3165
Yes, the parameters will be passed to login
method.
I see $form
being used in the form there, it appears you are using older version of cakephp (if $form
has been instantiated with $this->Form
then you are fine)
The FormHelper does lot of automagic
for us and it also provides us means for added security.
I would reckon you to go with The Blog tutorial
Upvotes: 1
Reputation: 303
You can use HTML for anything you want, but you'd be losing a big advantage of the CakePHP framework. The Cake HTML and form helpers help to future-proof your code. You also get the benefit of Cake's implementation of best practices in web coding. I fully recommend using those helpers.
The form data is passed to $this->request->data
.
Upvotes: 1