本文整理汇总了PHP中yii\base\Model::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::load方法的具体用法?PHP Model::load怎么用?PHP Model::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Model
的用法示例。
在下文中一共展示了Model::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performAjaxValidation
/**
* Performs model ajax validation
*
* @param Model $model
* @return array|null
*/
protected function performAjaxValidation(Model $model)
{
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && Yii::$app->request->post('ajax') == $model->formName()) {
// AJAX validation
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
return null;
}
示例2: performValidationModel
/**
* Performs ajax validation.
*
* @param \yii\base\Model $model
*
* @throws \yii\base\ExitException
*/
protected function performValidationModel(Model $model)
{
if ($model->load(Yii::$app->request->post())) {
return ActiveForm::validate($model);
}
return;
}
示例3: performAjaxValidation
/**
* Performs ajax validation.
* @param Model $model
* @throws \yii\base\ExitException
*/
protected function performAjaxValidation(Model $model)
{
if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
\Yii::$app->response->format = Response::FORMAT_JSON;
echo json_encode(ActiveForm::validate($model));
\Yii::$app->end();
}
}
示例4: performAjaxValidation
/**
* Performs ajax validation.
* @param Model $model
*/
protected function performAjaxValidation(Model $model)
{
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
}
示例5: load
/**
* Populates the model with input data.
* @param Model $model model instance.
* @param array $data the data array to load, typically `$_POST` or `$_GET`.
* @return boolean whether expected forms are found in `$data`.
*/
protected function load($model, $data)
{
/* @var $this Action */
$event = new ActionEvent($this, ['model' => $model, 'result' => $model->load($data)]);
$this->trigger('afterDataLoad', $event);
return $event->result;
}
示例6: load
public function load($data, $formName = null)
{
$isLoad = true;
foreach ($this->models as $key => $model) {
$isLoad = $model->load($data, $formName) && $isLoad;
}
return parent::load($data, $formName) && $isLoad;
}
示例7: load
/**
* @inheritdoc
*/
public function load($data, $formName = null)
{
$files = \yii\web\UploadedFile::getInstancesByName('logo');
if (count($files) != 0) {
$file = $files[0];
$this->logo = $file;
}
return parent::load($data, $formName);
}
示例8: load
public function load($data, $formName = null)
{
if (parent::load($data, $formName)) {
$this->file = UploadedFile::getInstance($this, 'file');
return true;
} else {
return false;
}
}
示例9: load
public function load($post)
{
if ($post["AdminUserFunctionsForm"]["id_user"]) {
foreach ($post["AdminUserFunctionsForm"]["id_user"] as $id_user) {
$this->id_user[] = $id_user;
}
}
return parent::load($post);
}
示例10: load
/**
* @inheritdoc
*/
public function load($data, $formName = null)
{
if (!parent::load($data, $formName)) {
return false;
}
$this->name = preg_replace('/\\s+/', '_', $this->name);
$this->name = preg_replace('/[^0-9a-zA-Z$_]+/', '', $this->name);
return true;
}
示例11: load
public function load($data = null, $formName = '')
{
parent::load($data, $formName);
foreach ($this->_defaults as $k => $v) {
if (is_null($this->{$k})) {
$this->{$k} = $v;
}
}
return true;
}
示例12: performAjaxValidation
protected function performAjaxValidation(Model $model)
{
$isAjaxRequest = \Yii::$app->request->isAjax();
$postData = \Yii::$app->request->post();
if ($isAjaxRequest && $model->load($postData)) {
Yii::$app->response->format = Response::FORMAT_JSON;
echo json_encode(ActiveForm::validate($model));
Yii::$app->end();
}
}
示例13: load
/**
* @inheritdoc
*/
public function load($data, $formName = '')
{
if (strlen($data['fqdn']) && strpos($data['fqdn'], '.') === false) {
if (strlen($data['zone'])) {
$data['fqdn'] .= '.' . $data['zone'];
unset($data['zone']);
} else {
$data['fqdn'] .= '.' . static::DEFAULT_ZONE;
}
}
return parent::load($data, $formName);
}
示例14: setAjaxData
/**
* Validate Form action
* @param Model $model
* @param string $action
* @return array
*/
public function setAjaxData(Model $model, $action = 'save', $json = false)
{
$response = ['status' => 0, 'errors' => '', 'text' => ''];
if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
if ($model->{$action}()) {
$response['status'] = 1;
} else {
$response['errors'] = Html::errorSummary($model);
}
}
return $json ? json_encode($response) : [$model, $response];
}
示例15: load
/**
* Populates the main model and variation models with input data.
* @param Model $model main model instance.
* @param array $data the data array to load, typically `$_POST` or `$_GET`.
* @return boolean whether expected forms are found in `$data`.
*/
protected function load($model, $data)
{
if (!$model->load($data)) {
return false;
}
foreach ($this->getVariationModelBatches($model) as $variationName => $variationModels) {
if (!Model::loadMultiple($variationModels, $data)) {
return false;
}
}
return true;
}