Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can use anonymous functions in twig? #48

Closed
yii-bot opened this issue Jan 24, 2016 · 1 comment
Closed

How can use anonymous functions in twig? #48

yii-bot opened this issue Jan 24, 2016 · 1 comment
Labels
type:docs Documentation

Comments

@yii-bot
Copy link

yii-bot commented Jan 24, 2016

This issue has originally been reported by @RooTooZ at yiisoft/yii2#8401.
Moved here by @cebe.


for example, I want to change the button setting

echo \yii\grid\GridView::widget([
     'id'=>'loggrid',
    'dataProvider' => $dp,
    'columns' => [
      ....
       [
           'class' => \yii\grid\ActionColumn::className(),
           'buttons'=>[
                  'view'=>function ($url, $model) { # how can use this option in twig???
                        $customurl=Yii::$app->getUrlManager()->createUrl(['log/view','id'=>$model['id']]); 
                        return \yii\helpers\Html::a( '<span class="glyphicon glyphicon-eye-open"></span>', $customurl,
                                                ['title' => Yii::t('yii', 'View'), 'data-pjax' => '0']);
               }
            ],
           'template'=>'{view}  {delete}',
       ]
    ],
]);
@antgubarev
Copy link
Contributor

You can not use anonymous function in twig template. See docs https://github.com/yiisoft/yii2-twig/blob/master/docs/guide/layouts-and-widgets.md

antichris pushed a commit to antichris/yii2-twig that referenced this issue Oct 14, 2017
antichris pushed a commit to antichris/yii2-twig that referenced this issue Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Documentation
Projects
None yet
Development

No branches or pull requests

3 participants