<?php
/* @var $this MenuItemController */
/* @var $model MenuItem */
/* @var $form CActiveForm */
$this->breadcrumbs = array(
    'Menus' => array('menu/admin'),
    Yii::t('admin', 'Menu: {menutitle}', array('{menutitle}' => $menu->title)) => array('admin', 'menu_id' => $model->menu_id),
    'Create',
);
if ($this->action->id === 'create')
    $this->pageTitle = Yii::t('admin', 'Create Menu Item');
else if ($this->action->id === 'update')
    $this->pageTitle = Yii::t('admin', 'Update Menu Item');
?>
<div class="page-header"><h1><?php echo $this->pageTitle; ?></h1></div>

<div class="col-xs-12">
    <?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'menu-item-form',
        'enableAjaxValidation' => false,
        'htmlOptions'=>array('enctype' => 'multipart/form-data')
    ));
    ?>
    <?php echo $form->errorSummary($model); ?>

    <div class="form-group">
        <label class="col-md-3 control-label">
            <?php echo Yii::t('admin', 'Add To Menu:'); ?>
        </label>

        <div class="col-md-5 controls">
            <?php echo $form->hiddenField($model, 'menu_id'); ?>

            <label>
                <?php echo $menu->title ?>
            </label>
        </div>
    </div>

    <?php echo $form->dropDownListControlGroup($model, 'parent_id', CHtml::listData($menuItems, 'id', 'title'), array('empty' => '', 'separator' => '')); ?>


    <?php echo $form->textFieldControlGroup($model, 'title', array('maxlength' => 100)); ?>
    <?php echo $form->textFieldControlGroup($model, 'en_title', array('maxlength' => 100)); ?>





    <?php
    echo $form->textFieldControlGroup($model, 'link', array(
        'maxlength' => 250,
        'append' => CHtml::link(Yii::t('admin', 'Select'), '#', array('onclick' => '$("#select-page-dialog").dialog("open"); return false;'))
            )
    );
    ?>
    <?php echo $this->renderPartial('_pageSelectDialog', array('model' => $model)); ?>


    <?php echo $form->dropDownListControlGroup($model, 'link_target', MenuItem::getLinkTargetList(), array('empty' => '')); ?>


    <?php echo $form->dropDownListControlGroup($model, 'visible', array(0 => Yii::t('admin', 'NO'), 1 => Yii::t('admin', 'YES'))); ?>

    <?php echo $form->textFieldControlGroup($model, 'bg_color'); ?>
    <?php echo $form->textFieldControlGroup($model, 'head_color'); ?>
    <?php echo $form->textFieldControlGroup($model, 'border_color'); ?>
    <?php echo $form->textFieldControlGroup($model, 'sort'); ?>
    <?php 
        echo $form->labelEx($model,'image'); 
        echo $form->fileField($model,'image');
    ?>

    <div class="widget-box collapsed">
        <div class="widget-header widget-header-small">

            <a href="widgets.html#" data-action="collapse">

                <h4><i class="icon-chevron-down"></i> <?php echo Yii::t('admin', 'Advanced Settings'); ?></h4>
            </a>
        </div>
        <div class="widget-body">
            <div class="widget-main">
                <?php echo $form->textFieldControlGroup($model, 'template', array('size' => 'sm', 'maxlength' => 45)); ?>

                <div class="form-group">
                    <?php echo $form->labelEx($model, 'link_options', array('class' => 'col-md-3 control-label')); ?>
                    <div class="col-md-5 controls">
                        <?php for ($index = 0; $index < 5; $index++): ?>
                            <div class="row">
                                <div class="col-xs-6">
                                    <?php echo $form->textField($model, "link_options[key][{$index}]", array('class' => 'form-control input-sm')); ?>
                                </div>
                                <div class="col-xs-6">
                                    <?php echo $form->textField($model, "link_options[value][{$index}]", array('class' => 'form-control input-sm')); ?>
                                </div>
                            </div>
                            <div class="space-2"></div>
                        <?php endfor; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>



    <?php //if (Yii::app()->options->get('I18N_MULTILINGUAL', 0) == 1): ?>

        <?php //echo $form->dropDownListControlGroup($model, 'language', FlexLocale::getActiveLocales(), array('empty' => '')); ?>

    <?php //endif; ?>

    <?php echo TbHtml::formActions(array(TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('color' => TbHtml::BUTTON_COLOR_PRIMARY)), TbHtml::resetButton('Reset'),)); ?>


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