Last active
October 1, 2015 06:27
-
-
Save jamband/1937187 to your computer and use it in GitHub Desktop.
Yii Framework: Example Twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'components' => array( | |
... | |
'viewRenderer' => array( | |
'class' => 'ext.ETwigViewRenderer', | |
'globals' => array( | |
'Yii' => 'Yii', | |
'Captcha' => 'CCaptcha', | |
), | |
'functions' => array( | |
'link' => 'CHtml::link', | |
'form' => 'CHtml::beginForm', | |
'endform' => 'CHtml::endForm', | |
'sform' => 'CHtml::statefulForm', | |
'errors' => 'CHtml::errorSummary', | |
'_text' => 'CHtml::textField', | |
'label' => 'CHtml::activeLabel', | |
'text' => 'CHtml::activeTextField', | |
'password' => 'CHtml::activePasswordField', | |
'checkbox' => 'CHtml::activeCheckBox', | |
'submit' => 'CHtml::submitButton', | |
), | |
), | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (Yii::app()->user->hasFlash('error')): ?> | |
<div class="flash-error"> | |
<div class="center"> | |
<?php echo Yii::app()->user->getFlash('error'); ?><br /> | |
<?php echo CHtml::link('新規登録画面に戻る', array('/user/register')); ?> | |
</div><!-- /.center --> | |
</div><!-- /.flash-error --> | |
<?php else: ?> | |
<p> | |
新規登録を行います<br /> | |
以下のフォームに必要な情報を入力してください | |
</p> | |
<div class="form"> | |
<?php echo CHtml::statefulForm(); ?> | |
<?php echo CHtml::errorSummary($model); ?> | |
<div class="row"> | |
<?php echo CHtml::activeLabel($model, 'username'); ?> | |
<?php echo CHtml::activeTextField($model, 'username', array('maxlength' => 32)); ?> | |
</div><!-- /.row --> | |
<div class="row"> | |
<?php echo CHtml::activeLabel($model, 'email'); ?> | |
<?php echo CHtml::activeTextField($model, 'email', array('maxlength' => 64)); ?> | |
</div><!-- /.row --> | |
<div class="row"> | |
<?php echo CHtml::activeLabel($model, 'password'); ?> | |
<?php echo CHtml::activePasswordField($model, 'password', array('maxlength' => 64)); ?> | |
</div><!-- /.row --> | |
<div class="row"> | |
<?php echo CHtml::activeLabel($model, 'verifyPassword'); ?> | |
<?php echo CHtml::activePasswordField($model, 'verifyPassword', array('maxlength' => 64)); ?> | |
</div><!-- /.row --> | |
<?php if (CCaptcha::checkRequirements()): ?> | |
<div class="row"> | |
<?php $this->widget('CCaptcha'); ?> | |
<?php echo CHtml::activeLabel($model, 'verifyCode'); ?> | |
<?php echo CHtml::activeTextField($model,'verifyCode'); ?> | |
</div><!-- /.row --> | |
<?php endif; ?> | |
<div class="row buttons"> | |
<?php echo CHtml::submitButton('登録内容を確認する', array('name' => 'confirm')); ?> | |
</div><!-- /.row buttons --> | |
<?php echo CHtml::endForm(); ?> | |
</div><!-- /.form --> | |
<?php endif; ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if App.user.hasFlash('error') %} | |
<div class="flash-error"> | |
<div class="center"> | |
{{ App.user.getFlash('error') }}<br /> | |
{{ link('新規登録画面に戻る', ['/user/register']) }} | |
</div><!-- /.center --> | |
</div><!-- /.flash-error --> | |
{% else %} | |
<p> | |
新規登録を行います<br /> | |
以下のフォームに必要な情報を入力してください | |
</p> | |
<div class="form"> | |
{{ sform() }} | |
{{ errors(model) }} | |
<div class="row"> | |
{{ label(model, 'username') }} | |
{{ text(model, 'username', {'maxlength': 32}) }} | |
</div><!-- /.row --> | |
<div class="row"> | |
{{ label(model, 'email') }} | |
{{ text(model, 'email', {'maxlength': 64}) }} | |
</div><!-- /.row --> | |
<div class="row"> | |
{{ label(model, 'password') }} | |
{{ password(model, 'password', {'maxlength': 64}) }} | |
</div><!-- /.row --> | |
<div class="row"> | |
{{ label(model, 'verifyPassword') }} | |
{{ password(model, 'verifyPassword', {'maxlength': 64}) }} | |
</div><!-- /.row --> | |
{% if Captcha.checkRequirements %} | |
<div class="row"> | |
{{ this.widget('CCaptcha', [], true) }} | |
{{ label(model, 'verifyCode') }} | |
{{ text(model, 'verifyCode') }} | |
</div><!-- /.row --> | |
{% endif %} | |
<div class="row buttons"> | |
{{ submit('登録内容を確認する', {'name': 'confirm'}) }} | |
</div><!-- /.row buttons --> | |
{{ endform() }} | |
</div><!-- /.form --> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment