<?php
/**
 * The following variables are available in this template:
 * @var $this CrudCode
 */
?>
<div class="form">

    <?php
    echo <<<EOD
    <?php
    /**
     * @var BHorizontalForm \$form
     * @var {$this->modelClass} \$model
     * @var {$this->i18nModelClass}[] \$i18nModels
     */
    ?>

EOD;
    ?>

    <?php echo "<?php \$form=\$this->beginWidget('BHorizontalForm', array(
	'id'=>'" . $this->class2id($this->modelClass) . "-form',
	'enableAjaxValidation'=>false,
    'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
    ),
)); ?>\n"; ?>
    <!--
    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <?php echo "<?php echo \$form->errorSummary(\$model); ?>\n"; ?>

    -->

    <?php
    foreach ($this->tableSchema->columns as $column) {
        if ($column->autoIncrement)
            continue;

        echo "    <div class=\"control-group <?php echo (\$model->hasErrors('{$column->name}') ? ' error' : '') ?>\">\n";
        echo "        <?php echo \$form->label(\$model, '{$column->name}', array('class' => 'control-label'))?>\n";
        echo "        <div class=\"controls\">\n";
        echo "            <?php echo " . $this->generateActiveField($this->modelClass, $column) . "; ?>\n";
        echo "            <?php echo \$form->error(\$model,'{$column->name}'); ?>\n";
        echo "        </div>\n";
        echo "    </div>\n\n";

    }
    echo <<<EOD
    <?php
    /**
     * @var BTabs \$tabs
     */
    \$tabs = \$this->beginWidget('BTabs');
    foreach (\$i18nModels as \$lang => \$i18nModel):
        ?>
        <?php \$tabs->beginTab(Yii::app()->params['languageNames'][\$lang]) ?>
EOD;
    foreach ($this->i18nTableSchema->columns as $column) {
        if ($column->autoIncrement || $column->name == 'lang' || $column->name == $this->tableSchema->primaryKey)
            continue;

        echo "        <div class=\"control-group <?php echo (\$i18nModel->hasErrors('{$column->name}') ? ' error' : '') ?>\">\n";
        echo "            <?php echo \$form->label(\$i18nModel, '{$column->name}', array('class' => 'control-label'))?>\n";
        echo "            <div class=\"controls\">\n";
        echo "                <?php echo " . $this->generateI18dActiveField($this->i18nModelClass, $column) . "; ?>\n";
        echo "                <?php echo \$form->error(\$i18nModel,'{$column->name}'); ?>\n";
        echo "            </div>\n";
        echo "        </div>\n\n";

    }
    echo <<<EOD
        <?php \$tabs->endTab() ?>
        <?php
    endforeach;
    \$this->endWidget();
    ?>
EOD;

    ?>


    <div class="form-actions">
        <button type="submit" class="btn btn-large btn-primary">
            <?php echo "<?php echo (\$model->isNewRecord ? 'Создать' : 'Сохранить'); ?>\n";?>
        </button>
    </div>

    <?php echo "<?php \$this->endWidget(); ?>\n"; ?>

</div><!-- form -->
