Question

I have a form that looks like so:

<?php
echo $this->form->create('User');
echo $this->form->input('username');
echo $this->form->input('email');
echo $this->form->input('password');
echo $this->form->end('Save');
?>

And a controller where the file is submitted:

if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) { 

        }

I am trying to get the input from the form as a variable. Something like..

if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) { 

          $username = $this->form->input('username');

        }

Is this possible? to get an input from the form and store it as a variable to use it for something else?

Thank you all in advance!

Using: Cakephp 2.x

Was it helpful?

Solution

This is how you access value

$this->request->data['User']['username']

Where User is name you put in $this->Form->create() and username is name of field

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top