<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model frontend\models\Option */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="option-form">
    <?php $form = ActiveForm::begin(); ?>
    <input type="hidden" name="Option[model]" value="<?=$modeldb?>"/>
    <input type="hidden" name="Option[model_id]" value="<?=$model_id?>"/>
	<?php foreach($models as $id => $row) {
        	?>
        	<label for="Option[<?=$id?>][<?=$key?>]"><?php echo Yii::t('app', $row->name); ?></label>
        	<input type="hidden" name="Option[<?=$id?>][id]" value="<?=$id?>" />
            <input type="hidden" name="Option[<?=$id?>][template]" value="<?=$row->template?>"/>
            <input type="<?=$row->template?>" name="Option[<?=$id?>][value][<?=$row->name?>]" class="form-control required" required value="<?=$modellang[$id][0]->value?>"/>
            <?php if($row->hasErrors()) { ?><div class="help-block"><?php echo $modellang[$id][0]->getFirstError('value');?></div> <?php } ?>
        	<?php
            if($row->translate) {
                foreach($row->getLangs() as $language_id => $lang) {
                ?>
                <div class="form-group">
                	<div class="col-xs-1"><?=$lang['lang_code']?></div>
                	<div class="col-xs-11"><input type="<?=$row->template?>" name="Option[<?=$id?>][lang][<?=$lang['language_id']?>]" class="form-control" value="<?=$modellang[$id][$lang['language_id']]->value?>"/></div>
                </div>
                <?php
                }
            }
        	
	}?>
	
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>
</div>
