how to get the value on form input in cakephp

10,872

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'
   )
));
Share:
10,872
John Micah Fernandez Miguel
Author by

John Micah Fernandez Miguel

Updated on June 04, 2022

Comments

  • John Micah Fernandez Miguel
    John Micah Fernandez Miguel almost 2 years

    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