метод populate
Добавлено: 2013.07.25, 15:41
Объясните, что за метод появился новый populate(), каково его функциональное назначение?
Код: Выделить всё
if(isset($_POST['form']))
{
$model->attributes=$_POST['form'];
}
Код: Выделить всё
if ($this->populate($_POST, $model))
{
}
Код: Выделить всё
if ($model->load($_POST) && $model->save()) {
}
Код: Выделить всё
public function submitted($method='post')
{
$method=ucfirst(strtolower($method));
if ($method==='Get')$method='Query';
if (!in_array($method, array('Post','Put','Query','Delete')))
throw new \CException('Method error');
$method='get'.$method;
$data=\Yii::app()->getRequest()->{$method}(get_class($this));
if ($submitted=is_array($data))
$this->setAttributes($data);
return $submitted;
}