public function asCrudLink($value, $options = [], $action = 'view', $label = null)
    {
        if ($value === null || (is_array($value) && empty($value))) {
            return $this->nullDisplay;
        }
        $values = is_array($value) ? $value : [$value];

        $route = false;
        $result = [];
        foreach ($values as $value) {
            if ($label === null) {
                $labelString = Html::encode((string)$value);
            } elseif (is_callable($label)) {
                $labelString = call_user_func($label, $value);
            } else {
                $labelString = $label;
            }
            if (!$value instanceof ActiveRecord) {
                $result[] = $labelString;
                continue;
            }
            if ($route === false) {
                $route = Yii::$app->crudModelsMap[$value::className()];
            }
            if ($route === null || !Yii::$app->user->can($value::className().'.read', ['model' => $value])) {
                $result[] = $labelString;
                continue;
            }

            $result[] = Html::a($labelString, [
                $route . '/' . $action,
                'id' => Action::exportKey($value->getPrimaryKey()),
            ], $options);
        }
        return implode(', ', $result);
    }
public function asCrudLink($value, $options = [], $action = 'view', $label = null)
    {
        if ($value === null || (is_array($value) && empty($value))) {
            return $this->nullDisplay;
        }
        $values = is_array($value) ? $value : [$value];

        $route = false;
        $result = [];
        foreach ($values as $value) {
            if ($label === null) {
                $labelString = Html::encode((string)$value);
            } elseif (is_callable($label)) {
                $labelString = call_user_func($label, $value);
            } else {
                $labelString = $label;
            }
            if (!$value instanceof ActiveRecord) {
                $result[] = $labelString;
                continue;
            }
            if ($route === false) {
                $route = Yii::$app->crudModelsMap[$value::className()];
            }
            if ($route === null || !Yii::$app->user->can($value::className().'.read', ['model' => $value])) {
                $result[] = $labelString;
                continue;
            }

            $result[] = Html::a($labelString, [
                $route . '/' . $action,
                'id' => Action::exportKey($value->getPrimaryKey()),
            ], $options);
        }
        return implode(', ', $result);
    }
public function asCrudLink ( $ value , $ options = [ ] , $ action = 'view' , $ label = null ) { if ( $ value === null || ( is_array ( $ value ) && empty ( $ value ) ) ) { return $ this -> nullDisplay ; } $ values = is_array ( $ value ) ? $ value : [ $ value ] ; $ route = false ; $ result = [ ] ; foreach ( $ values as $ value ) { if ( $ label === null ) { $ labelString = Html :: encode ( ( string ) $ value ) ; } elseif ( is_callable ( $ label ) ) { $ labelString = call_user_func ( $ label , $ value ) ; } else { $ labelString = $ label ; } if ( ! $ value instanceof ActiveRecord ) { $ result [ ] = $ labelString ; continue ; } if ( $ route === false ) { $ route = Yii :: $ app -> crudModelsMap [ $ value :: className ( ) ] ; } if ( $ route === null || ! Yii :: $ app -> user -> can ( $ value :: className ( ) . '.read' , [ 'model' => $ value ] ) ) { $ result [ ] = $ labelString ; continue ; } $ result [ ] = Html :: a ( $ labelString , [ $ route . '/' . $ action , 'id' => Action :: exportKey ( $ value -> getPrimaryKey ( ) ) , ] , $ options ) ; } return implode ( ', ' , $ result ) ; }
Formats the value as a link to a matching controller.
@param Model|Model[] $value the value to be formatted.
@param array $options the tag options in terms of name-value pairs. See [[Html::a()]].
@param string $action name of the action to link to
@param string|callable $label if not null, will be used instead of casting the value to string, should be encoded
@return string the formatted result.
Formats the value as a link to a matching controller .