當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。