<?php
$this->pageTitle = Yii::app()->name . ' - ' . UsuarioModule::t("Registration");
$this->breadcrumbs = array(
    UsuarioModule::t("Registration"),
);
?>

<h1><?php echo UsuarioModule::t("Registration"); ?></h1>

    <?php if (Yii::app()->user->hasFlash('registration')): ?>
    <div class="success">
    <?php echo Yii::app()->user->getFlash('registration'); ?>
    </div>
<?php else: ?>

    <div class="form">
        <?php
        $form = $this->beginWidget('CActiveForm', 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 UsuarioModule::t('Fields with <span class="required">*</span> are required.'); ?></p>

            <?php echo $form->errorSummary(array($model, $perfil)); ?>

        <div class="row">
    <?php echo $form->labelEx($model, 'username'); ?>
    <?php echo $form->textField($model, 'username'); ?>
            <?php echo $form->error($model, 'username'); ?>
        </div>

        <div class="row">
                <?php echo $form->labelEx($model, 'password'); ?>
                <?php echo $form->passwordField($model, 'password'); ?>
    <?php echo $form->error($model, 'password'); ?>
            <p class="hint">
    <?php echo UsuarioModule::t("Minimal password length 4 symbols."); ?>
            </p>
        </div>

        <div class="row">
    <?php echo $form->labelEx($model, 'confirmacion_password'); ?>
    <?php echo $form->passwordField($model, 'confirmacion_password'); ?>
            <?php echo $form->error($model, 'confirmacion_password'); ?>
        </div>

        <div class="row">
    <?php echo $form->labelEx($model, 'email'); ?>
        <?php echo $form->textField($model, 'email'); ?>
        <?php echo $form->error($model, 'email'); ?>
        </div>

        <?php
        $perfilFields = Perfil::getFields();
        if ($perfilFields) {
            foreach ($perfilFields as $field) {
                ?>
                <div class="row">
                    <?php echo $form->labelEx($perfil, $field->varname); ?>
                    <?php
                    if ($widgetEdit = $field->widgetEdit($perfil)) {
                        echo $widgetEdit;
                    } elseif ($field->range) {
                        echo $form->dropDownList($perfil, $field->varname, Perfil::range($field->range));
                    } elseif ($field->field_type == "TEXT") {
                        echo$form->textArea($perfil, $field->varname, array('rows' => 6, 'cols' => 50));
                    } else {
                        echo $form->textField($perfil, $field->varname, array('size' => 60, 'maxlength' => (($field->field_size) ? $field->field_size : 255)));
                    }
                    ?>
                <?php echo $form->error($perfil, $field->varname); ?>
                </div>	
                <?php
            }
        }
        ?>
            <?php if (UsuarioModule::doCaptcha('registration')): ?>
            <div class="row">
                <?php echo $form->labelEx($model, 'verifyCode'); ?>

        <?php $this->widget('CCaptcha'); ?>
        <?php echo $form->textField($model, 'verifyCode'); ?>
        <?php echo $form->error($model, 'verifyCode'); ?>

                <p class="hint"><?php echo UsuarioModule::t("Please enter the letters as they are shown in the image above."); ?>
                    <br/><?php echo UsuarioModule::t("Letters are not case-sensitive."); ?></p>
            </div>
            <?php endif; ?>

        <div class="row submit">
        <?php echo CHtml::submitButton(UsuarioModule::t("Register")); ?>
        </div>

    <?php $this->endWidget(); ?>
    </div><!-- form -->
<?php endif; ?>