Sunday, March 13, 2022

[FIXED] how to get the value on form input in cakephp

Issue

I have:

echo $this->Form->input('username', array('label' => 'Username: '));

equivalent to in traditional php coding..

how can I get the value inputted in that textbox like when you do $val = $_POST['username']; in traditional php coding.

I need this for login validation. thanks


Solution

You can get it

$val = $this->data['ModelName']['username']; //CakePHP 1.X.X

//or

$this->request->data['ModelName']['username']); //CakePHP 2.X.X

Where "ModelName" is your currently assigned model to form.

Update:

$user = $this->Account->find('first', array(
   'conditions' => array(
      'username' => 'user1'
   )
));


Answered By - Aurimas Ličkus

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.