当前位置: 首页>>代码示例>>PHP>>正文


PHP Model::formName方法代码示例

本文整理汇总了PHP中yii\base\Model::formName方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::formName方法的具体用法?PHP Model::formName怎么用?PHP Model::formName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\base\Model的用法示例。


在下文中一共展示了Model::formName方法的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;
 }
开发者ID:kalyabin,项目名称:comitka,代码行数:15,代码来源:ProfileController.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->header) {
         $this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
     }
 }
开发者ID:cranky4,项目名称:change-log-behavior,代码行数:10,代码来源:ChangeLogList.php

示例3: onLoad

 /**
  * Берет значения из POST и возвраает знаяения для добавления в БД
  *
  * @param array           $field
  * @param \yii\base\Model $model
  *
  * @return array
  */
 public static function onLoad($field, $model)
 {
     $fieldName = $field[BaseForm::POS_DB_NAME];
     $value = ArrayHelper::getValue(\Yii::$app->request->post(), $model->formName() . '.' . $fieldName, false);
     if ($value) {
         $value = true;
     }
     $model->{$fieldName} = $value;
 }
开发者ID:CAPITALOV,项目名称:capitalov,代码行数:17,代码来源:CheckBox.php

示例4: formName

 /**
  * @inheritdoc
  */
 public function formName()
 {
     if (!empty($this->_formName)) {
         return $this->_formName;
     } else {
         return parent::formName();
     }
 }
开发者ID:consultnn,项目名称:yii2-mongodb-embedded,代码行数:11,代码来源:EmbeddedDocument.php

示例5: getCategory

 /**
  * @param \yii\base\Model $model
  *
  * @return string
  */
 protected function getCategory(Model $model)
 {
     if (!$model->isNewRecord) {
         $id = $model->id;
         $category = self::className() . ':' . $model->formName() . '-' . $id;
     } else {
         $category = self::className() . ':' . $model->formName();
     }
     return $category;
 }
开发者ID:cranky4,项目名称:change-log-behavior,代码行数:15,代码来源:ChangeLog.php

示例6: getCountAttempts

 /**
  * @return integer
  */
 protected function getCountAttempts()
 {
     if (!isset($this->_attemptsCount)) {
         $this->_attemptsCount = (new Query())->from($this->table)->where(['form' => $this->owner->formName(), 'ip' => ip2long(Yii::$app->getRequest()->getUserIP())])->count('*', $this->db);
     }
     return $this->_attemptsCount;
 }
开发者ID:heartshare,项目名称:linuxforum,代码行数:10,代码来源:CaptchaBehavior.php

示例7: onUpdate

 /**
  * Берет значения из POST и возвраает знаяения для добавления в БД
  *
  * @param array           $field
  * @param \yii\base\Model $model
  *
  * @return array
  */
 public static function onUpdate($field, $model)
 {
     $fieldName = $field[BaseForm::POS_DB_NAME];
     $value = ArrayHelper::getValue(\Yii::$app->request->post(), $model->formName() . '.' . $fieldName, null);
     if ($value == '') {
         $value = null;
     }
     return [$fieldName => $value];
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:17,代码来源:RadioList.php

示例8: getValue

 /**
  * Возвращает массив идентификаторов которые были отмечены
  *
  * @param array           $field
  * @param \yii\base\Model $model
  *
  * @return array [1, 2, 3, ... ] массив идентификаторов
  */
 public static function getValue($field, $model)
 {
     $fieldName = $field[BaseForm::POS_DB_NAME];
     $value = ArrayHelper::getValue(Yii::$app->request->post(), $model->formName() . '.' . $fieldName, []);
     return $value;
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:14,代码来源:CheckBoxListMask.php

示例9: onUpdate

 /**
  *
  * @param array           $field
  * @param \yii\base\Model $model
  *
  * @return array
  */
 public static function onUpdate($field, $model)
 {
     $fieldName = $field[BaseForm::POS_DB_NAME];
     $post = \Yii::$app->request->post()[$model->formName()];
     $fieldIntCountry = $fieldName . '_country';
     $fieldIntRegion = $fieldName . '_region';
     $fieldIntTown = $fieldName . '_town';
     $fieldTextCountry = $fieldName . '_country-name';
     $fieldTextRegion = $fieldName . '_region-name';
     $fieldTextTown = $fieldName . '_town-name';
     $valueTextCountry = ArrayHelper::getValue($post, $fieldTextCountry, '');
     $valueTextRegion = ArrayHelper::getValue($post, $fieldTextRegion, '');
     $valueTextTown = ArrayHelper::getValue($post, $fieldTextTown, '');
     if ($valueTextCountry == '' && $valueTextRegion == '' && $valueTextTown == '') {
         return [$fieldIntCountry => null, $fieldIntRegion => null, $fieldIntTown => null];
     }
     if ($valueTextCountry != '' && $valueTextRegion == '' && $valueTextTown == '') {
         return [$fieldIntCountry => ArrayHelper::getValue($post, $fieldIntCountry, null), $fieldIntRegion => null, $fieldIntTown => null];
     }
     if ($valueTextCountry != '' && $valueTextRegion != '' && $valueTextTown == '') {
         return [$fieldIntCountry => ArrayHelper::getValue($post, $fieldIntCountry, null), $fieldIntRegion => ArrayHelper::getValue($post, $fieldIntRegion, null), $fieldIntTown => null];
     }
     return [$fieldIntCountry => ArrayHelper::getValue($post, $fieldIntCountry, null), $fieldIntRegion => ArrayHelper::getValue($post, $fieldIntRegion, null), $fieldIntTown => ArrayHelper::getValue($post, $fieldIntTown, null)];
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:31,代码来源:Place.php

示例10: setUploadedFile

 /**
  * Emulates file uploading with existing file.
  * @param $model
  * @param $attribute
  * @param array $options =
  * ['name' => 'file.jpg', 'type' => 'image/jpeg', 'tmp_name' => '/tmp/asdZXC', 'error' => 0, 'size' => 123123]
  */
 public static function setUploadedFile(Model $model, $attribute, $options = [])
 {
     foreach ($options as $name => $value) {
         $_FILES[$model->formName()][$name][$attribute] = $value;
     }
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:13,代码来源:FormHelper.php

示例11: getFormNgModel

 /**
  * Generates the hierarchy to access the ngModel under the $form object in the AngularJS scope.
  * @param Model $model
  * @param string $attribute
  * @return string
  */
 public static function getFormNgModel($model, $attribute)
 {
     $formName = $model->formName();
     return $formName == '' ? $attribute : "{$formName}.{$attribute}";
 }
开发者ID:undefinedstudio,项目名称:yii2-angular-form,代码行数:11,代码来源:Html.php

示例12: formName

 public function formName()
 {
     $event = new FormNameEvent(['formName' => parent::formName()]);
     $this->trigger(self::EVENT_FORM_NAME, $event);
     return $event->formName;
 }
开发者ID:gromver,项目名称:yii2-models,代码行数:6,代码来源:BaseModel.php

示例13: formName

 /**
  * @return string
  */
 public function formName()
 {
     return $this->_formName ?: parent::formName();
 }
开发者ID:maddoger,项目名称:yii2-cms-core,代码行数:7,代码来源:ConfigurationModel.php

示例14: onLoad

 /**
  * @param array           $field
  * @param \yii\base\Model $model
  *
  * @return bool
  */
 public static function onLoad($field, $model)
 {
     $fieldName = $field[BaseForm::POS_DB_NAME];
     $modelName = $model->formName();
     $valueUrl = ArrayHelper::getValue(Yii::$app->request->post(), $modelName . '.' . $fieldName . '-url', '');
     $value = ArrayHelper::getValue(Yii::$app->request->post(), $modelName . '.' . $fieldName . '-value', '');
     $model->{$fieldName} = ['url' => $valueUrl, 'file' => UploadedFile::getInstance($model, $fieldName), 'value' => $value];
     return true;
 }
开发者ID:dram1008,项目名称:library,代码行数:15,代码来源:FileUpload.php

示例15: onLoad

 /**
  * @param array           $field
  * @param \yii\base\Model $model
  *
  * @return array поля для обновления в БД
  */
 public static function onLoad($field, $model)
 {
     $fieldName = $field[\cs\base\BaseForm::POS_DB_NAME];
     $array = Yii::$app->request->post($model->formName());
     $value = ArrayHelper::getValue($array, $fieldName, '');
     if ($value == '') {
         $model->{$fieldName} = null;
     } else {
         $dateFormat = ArrayHelper::getValue($field, 'widget.1.dateFormat', 'php:d.m.Y');
         if (strncmp($dateFormat, 'php:', 4) === 0) {
             $dateFormat = substr($dateFormat, 4);
         } else {
             $dateFormat = FormatConverter::convertDateIcuToPhp($dateFormat);
         }
         $model->{$fieldName} = \DateTime::createFromFormat($dateFormat, $value);
     }
 }
开发者ID:CAPITALOV,项目名称:capitalov,代码行数:23,代码来源:DatePicker.php


注:本文中的yii\base\Model::formName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。