<?php
$this->pageTitle = Yii::app()->name . ' - ' . UserModule::t("Registration");
$this->breadcrumbs = array(
    UserModule::t("Registration"),
);
?>
<div class="page-header"><h1><?php echo UserModule::t("Registration"); ?></h1></div>
<?php if (Yii::app()->user->hasFlash('registration')): ?>
    <div class="success">
        <?php echo Yii::app()->user->getFlash('registration'); ?>
    </div>
<?php else: ?>
    <div class="col-xs-12">
        <?php
        $form = $this->beginWidget('UActiveForm', array(
            'id' => 'registration-form',
            'enableAjaxValidation' => true,
            'disableAjaxValidationAttributes' => array('RegistrationForm_verifyCode'),
            'clientOptions' => array(
                'validateOnSubmit' => true,
            ),
            'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
        ?>
        <!--<p class="note"><?php echo UserModule::t('Fields with <span class="required">*</span> are required.'); ?></p>-->
        <?php echo $form->errorSummary(array($model, $profile)); ?>
        <?php echo $form->textFieldControlGroup($model, 'username'); ?>
        <?php echo $form->passwordField($model, 'password'); ?>
        <p class="hint">
            <?php echo UserModule::t("Minimal password length 4 symbols."); ?>
        </p>
        <?php echo $form->passwordField($model, 'verifyPassword'); ?>
        <?php echo $form->textFieldControlGroup($model, 'email'); ?>
        <?php
        $profileFields = $profile->getFields();
        if ($profileFields) {
            foreach ($profileFields as $field) {
                ?>
                <?php echo $form->labelEx($profile, $field->varname); ?>
                <?php
                if ($widgetEdit = $field->widgetEdit($profile)) {
                    echo $widgetEdit;
                } elseif ($field->range) {
                    echo $form->dropDownListControlGroup($profile, $field->varname, Profile::range($field->range));
                } elseif ($field->field_type == "TEXT") {
                    echo$form->textAreaControlGroup($profile, $field->varname, array('rows' => 6, 'cols' => 50));
                } else {
                    echo $form->textFieldControlGroup($profile, $field->varname, array('maxlength' => (($field->field_size) ? $field->field_size : 255)));
                }
                ?>
                <?php echo $form->error($profile, $field->varname); ?>
                <?php
            }
        }
        ?>
        <?php if (UserModule::doCaptcha('registration')): ?>
            <?php $this->widget('CCaptcha'); ?>
            <?php echo $form->textFieldControlGroup($model, 'verifyCode'); ?>
            <p class="hint"><?php echo UserModule::t("Please enter the letters as they are shown in the image above."); ?>
                <br/><?php echo UserModule::t("Letters are not case-sensitive."); ?></p>
        <?php endif; ?>
        <div class="row submit">
            <?php echo CHtml::submitButton(UserModule::t("Register")); ?>
        </div>
        <?php $this->endWidget(); ?>
    </div>
<?php endif; ?>