Yii2: AuthChoice widget customization - displaying default client links also.

Created on 7 Dec 2014  路  3Comments  路  Source: yiisoft/yii2

I am trying to customize AuthChoice with begin and end as mentioned in the Authchoice.php documentation.
I wanted to render the below button foreach client

Html::a( 'Log in with '. $client->title, ['site/auth', 'authclient'=> $client->name, ], ['class' => "btn btn-block btn-default $client->name "])

But AuthChoice is displaying the default buttons/clients also.

Most helpful comment

Thanks Venu85 this solved my problem. Just for a people new to yii2 (like me) the code snippet looks like below (add it to your view page)

<?php use yii\authclient\widgets\AuthChoice; ?>
<?php $authAuthChoice = AuthChoice::begin(['baseAuthUrl' => ['site/auth'], 'autoRender' => false]); ?>
<ul>
<?php foreach ($authAuthChoice->getClients() as $client): ?>
<li><?= Html::a( 'Log in with '. $client->title, ['site/auth', 'authclient'=> $client->name, ], ['class' => "btn btn-block btn-default $client->name "]) ?></li>
<?php endforeach; ?>
</ul>
<?php AuthChoice::end(); ?>

All 3 comments

Solved by setting the below property
'autoRender' => false

Thanks Venu85 this solved my problem. Just for a people new to yii2 (like me) the code snippet looks like below (add it to your view page)

<?php use yii\authclient\widgets\AuthChoice; ?>
<?php $authAuthChoice = AuthChoice::begin(['baseAuthUrl' => ['site/auth'], 'autoRender' => false]); ?>
<ul>
<?php foreach ($authAuthChoice->getClients() as $client): ?>
<li><?= Html::a( 'Log in with '. $client->title, ['site/auth', 'authclient'=> $client->name, ], ['class' => "btn btn-block btn-default $client->name "]) ?></li>
<?php endforeach; ?>
</ul>
<?php AuthChoice::end(); ?>

How can I open the same in default dialog box with customized widget.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

njasm picture njasm  路  44Comments

samdark picture samdark  路  63Comments

Mirocow picture Mirocow  路  56Comments

AstRonin picture AstRonin  路  49Comments

Faryshta picture Faryshta  路  48Comments