/**
  * Parses and returns the attribute
  */
 protected function parseAttributeItem($attribute)
 {
     if (is_string($attribute)) {
         if (!preg_match('/^([\\w\\.]+)(:(\\w*))?(:(.*))?$/', $attribute, $matches)) {
             throw new InvalidConfigException('The attribute must be specified in the format of "attribute", "attribute:format" or "attribute:format:label"');
         }
         $attribute = ['attribute' => $matches[1], 'format' => isset($matches[3]) ? $matches[3] : 'text', 'label' => isset($matches[5]) ? $matches[5] : null];
     }
     if (!is_array($attribute)) {
         throw new InvalidConfigException('The attribute configuration must be an array.');
     }
     if (isset($attribute['columns'])) {
         foreach ($attribute['columns'] as $j => $child) {
             $attribute['columns'][$j] = $this->parseAttributeItem($child);
         }
         return $attribute;
     }
     if (!empty($attribute['updateAttr'])) {
         $attrib = $attribute['updateAttr'];
         if (ctype_alnum(str_replace('_', '', $attrib))) {
             return;
         } else {
             throw new InvalidConfigException("The 'updateAttr' name '{$attrib}' is invalid.");
         }
     }
     $attrib = ArrayHelper::getValue($attribute, 'attribute', '');
     if ($attrib && strpos($attrib, '.') !== false) {
         throw new InvalidConfigException("The attribute '{$attrib}' is invalid. You cannot directly pass relational " . "attributes in string format within '\\kartik\\widgets\\DetailView'. Instead " . "use the array format with 'attribute' property set to base field, and the " . "'value' property returning the relational data. You can also override the " . "widget 'model' settings by setting the 'viewModel' and / or 'editModel' at " . "the attribute array level.");
     }
     if (isset($attribute['visible']) && !$attribute['visible']) {
         unset($this->attributes[$i]);
         continue;
     }
     if (!isset($attribute['format'])) {
         $attribute['format'] = 'text';
     }
     if (isset($attribute['attribute'])) {
         $attributeName = $attribute['attribute'];
         $model = !empty($attribute['viewModel']) && $attribute['viewModel'] instanceof Model ? $attribute['viewModel'] : $this->model;
         if (!isset($attribute['label'])) {
             $attribute['label'] = $model instanceof Model ? $model->getAttributeLabel($attributeName) : Inflector::camel2words($attributeName, true);
         }
         if (!array_key_exists('value', $attribute)) {
             $attribute['value'] = ArrayHelper::getValue($model, $attributeName);
         }
     } elseif (!isset($attribute['label']) || !array_key_exists('value', $attribute)) {
         if (ArrayHelper::getValue($attribute, 'group', false) || isset($attribute['columns'])) {
             $attribute['value'] = '';
             return $attribute;
         }
         throw new InvalidConfigException('The attribute configuration requires the "attribute" element to determine the value and display label.');
     }
     return $attribute;
 }
Exemple #2
0
            <div class="easyui-layout" data-options="fit:true">
                <div region="north" border="false" style="height: 80px;">
                    <h1>
                        <?php 
echo '&nbsp;' . Html::encode($this->title);
?>
                        <small><?php 
echo \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id;
?>
</small>
                    </h1>
                    <?php 
$breadcrumbs = isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [];
foreach (Yii::$app->controller->modules as $module) {
    if ($module != Yii::$app) {
        array_unshift($breadcrumbs, ['label' => Inflector::camel2words($module->id), 'url' => ['/' . $module->uniqueId]]);
    }
}
?>
                    <?php 
echo Breadcrumbs::widget(['tag' => 'ol', 'encodeLabels' => false, 'homeLink' => ['label' => '<i class="fa fa-dashboard"></i> Home/Dashboard', 'url' => ['/site/index']], 'links' => $breadcrumbs]);
?>
                </div>
                <div region="center">
                    <?php 
echo $content;
?>
                </div>
            </div>
        </div>
        <?php