عثمان غني
عثمان غني

Reputation: 2708

How to assign name to form in cakephp

I am making form in CakePHP I want the HTML for that form as below

<form action="/abc/sessionapps/login" name="UserLoginForm" id="UserLoginForm" method="post" accept-charset="utf-8">

Till now I have written following code in CakePHP

echo $this->Form->create('User', array('url' => array('controller' => 'sessionapps', 'action' =>'login'),array('name'=>'UserLoginForm')));

It is generating following output

<form action="/abc/sessionapps/login" 0="0" id="UserLoginForm" method="post" accept-charset="utf-8">

Please Help

Thanks in advance

Upvotes: 0

Views: 806

Answers (2)

cartina
cartina

Reputation: 1419

<?php
echo $this->Form->create('User', array('name'=>'UserLoginForm','url' => array('controller' => 'sessionapps', 'action' =>'login')));
?>

Generally we give the model name as the form name so that we get the array as $this->data[Model] and we can save it simply passing this array to the save query.

Upvotes: 1

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

try:

echo $this->Form->create('User', 
   array(
      'url' => array('controller' => 'sessionapps', 'action' =>'login'), 
      'name' => 'UserLoginForm' 
   )
);

Upvotes: 1

Related Questions