mootensai\enhancedgii\crud\Generator::generateDetailViewField PHP Метод

generateDetailViewField() публичный Метод

Generates code for Grid View field
public generateDetailViewField ( string $attribute, $fk, yii\db\TableSchema $tableSchema = null ) : string
$attribute string
$tableSchema yii\db\TableSchema
Результат string
    public function generateDetailViewField($attribute, $fk, $tableSchema = null)
    {
        if (is_null($tableSchema)) {
            $tableSchema = $this->getTableSchema();
        }
        if (in_array($attribute, $this->hiddenColumns)) {
            return "['attribute' => '{$attribute}', 'visible' => false],\n";
        }
        $humanize = Inflector::humanize($attribute, true);
        if ($tableSchema === false || !isset($tableSchema->columns[$attribute])) {
            if (preg_match('/^(password|pass|passwd|passcode)$/i', $attribute)) {
                return "";
            } else {
                return "'{$attribute}',\n";
            }
        }
        $column = $tableSchema->columns[$attribute];
        $format = $this->generateColumnFormat($column);
        //        if($column->autoIncrement){
        //            return "";
        //        } else
        if (array_key_exists($attribute, $fk)) {
            $rel = $fk[$attribute];
            $labelCol = $this->getNameAttributeFK($rel[3]);
            //            $humanize = Inflector::humanize($rel[3]);
            //            $id = 'grid-' . Inflector::camel2id(StringHelper::basename($this->searchModelClass)) . '-' . $attribute;
            //            $modelRel = $rel[2] ? lcfirst(Inflector::pluralize($rel[1])) : lcfirst($rel[1]);
            $output = "[\r\n            'attribute' => '{$rel['7']}.{$labelCol}',\r\n            'label' => " . $this->generateString(ucwords(Inflector::humanize($rel[5]))) . ",\r\n        ],\n";
            return $output;
        } else {
            return "'{$attribute}" . ($format === 'text' ? "" : ":" . $format) . "',\n";
        }
    }