[英]CakePHP - Get a variable from Post
我有一個看起來像這樣的表格:
<?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');
?>
以及提交文件的控制器:
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
}
我正在嘗試從表單獲取輸入作為變量。 就像是..
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$username = $this->form->input('username');
}
這可能嗎? 從表單獲取輸入並將其存儲為變量以用於其他用途?
謝謝大家!
使用:Cakephp 2.x
這就是您獲取價值的方式
$this->request->data['User']['username']
User
名是您在$this->Form->create()
username
的名稱, username
是字段名
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.