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


PHP Model::getAttributeHint方法代码示例

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


在下文中一共展示了Model::getAttributeHint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: activeHint

 /**
  * Generates a hint tag for the given model attribute.
  * The hint text is the hint associated with the attribute, obtained via [[Model::getAttributeHint()]].
  * If no hint content can be obtained, method will return an empty string.
  * @param Model $model the model object
  * @param string $attribute the attribute name or expression. See [[getAttributeName()]] for the format
  * about attribute expression.
  * @param array $options the tag options in terms of name-value pairs. These will be rendered as
  * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
  * If a value is null, the corresponding attribute will not be rendered.
  * The following options are specially handled:
  *
  * - hint: this specifies the hint to be displayed. Note that this will NOT be [[encode()|encoded]].
  *   If this is not set, [[Model::getAttributeHint()]] will be called to get the hint for display
  *   (without encoding).
  *
  * See [[renderTagAttributes()]] for details on how attributes are being rendered.
  *
  * @return string the generated hint tag
  * @since 2.0.4
  */
 public static function activeHint($model, $attribute, $options = [])
 {
     $attribute = static::getAttributeName($attribute);
     $hint = isset($options['hint']) ? $options['hint'] : $model->getAttributeHint($attribute);
     if (empty($hint)) {
         return '';
     }
     $tag = ArrayHelper::remove($options, 'tag', 'div');
     unset($options['hint']);
     return static::tag($tag, $hint, $options);
 }
开发者ID:Kest007,项目名称:yii2,代码行数:32,代码来源:BaseHtml.php


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