문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top