本文整理汇总了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;
}
示例2: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!$this->header) {
$this->header = "<h2>" . Inflector::camel2words($this->model->formName()) . " change log:</h2>";
}
}
示例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;
}
示例4: formName
/**
* @inheritdoc
*/
public function formName()
{
if (!empty($this->_formName)) {
return $this->_formName;
} else {
return parent::formName();
}
}
示例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;
}
示例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;
}
示例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];
}
示例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;
}
示例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)];
}
示例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;
}
}
示例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}";
}
示例12: formName
public function formName()
{
$event = new FormNameEvent(['formName' => parent::formName()]);
$this->trigger(self::EVENT_FORM_NAME, $event);
return $event->formName;
}
示例13: formName
/**
* @return string
*/
public function formName()
{
return $this->_formName ?: parent::formName();
}
示例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;
}
示例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);
}
}