1

I have the following Yii code and would like to minimise it if possible:

$request = Yii::app()->request->getPost('request');
$username = $request['model']['username'];

Is it possible to minimise this to have this work something like this so its all on a single line for instance? (note the code below doesn't work)

$username = Yii::app()->request->getPost('request['model']['username']'); 
Zabs
  • 13,852
  • 45
  • 173
  • 297

1 Answers1

1

as you can see below (in class CHttpRequest):

public function getPost($name,$defaultValue=null)
{
    return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
}

if you can put it in $name, it will get returned :D

Developerium
  • 7,155
  • 5
  • 36
  • 56