_form.php 4.32 KB
<?php
    
    use artbox\catalog\models\Variant;
    use artbox\catalog\models\VariantLang;
    use artbox\catalog\models\VariantOptionGroupCompl;
    use artbox\catalog\models\VariantOptionGroupExcl;
    use yii\bootstrap\Tabs;
    use yii\helpers\Html;
    use yii\web\View;
    use yii\widgets\ActiveForm;
    
    /**
     * @var VariantLang[]             $modelLangs
     * @var Variant                   $model
     * @var ActiveForm                $form
     * @var View                      $this
     * @var VariantOptionGroupCompl[] $groups_compl
     * @var VariantOptionGroupExcl[]  $groups_excl
     * @var \artbox\stock\models\Shop $shops;
     */
?>

<div class="variant-form">
    
    <?php $form = ActiveForm::begin(); ?>
    
    <?php
        echo Tabs::widget(
            [
                'items'   => [
                    [
                        'label'   => \Yii::t('catalog', 'Common'),
                        'content' => $this->render(
                            '_form_common',
                            [
                                'form'       => $form,
                                'model'      => $model,
                                'modelLangs' => $modelLangs,
                            ]
                        ),
                        'active'  => true,
                    ],
                    [
                        'label'         => \Yii::t('catalog', 'Options'),
                        'content'       => $this->render(
                            '_form_options',
                            [
                                'form'         => $form,
                                'model'        => $model,
                                'modelLangs'   => $modelLangs,
                                'groups_compl' => $groups_compl,
                                'groups_excl'  => $groups_excl,
                            ]
                        ),
                        'headerOptions' => [
                            'class'               => ( empty( $groups_compl ) && empty( $groups_excl ) ) ? 'disabled' : '',
                            'data-toggle'         => ( empty( $groups_compl ) && empty( $groups_excl ) ) ? 'tooltip' : '',
                            'data-placement'      => ( empty( $groups_compl ) && empty( $groups_excl ) ) ? 'top' : '',
                            'data-original-title' => ( empty( $groups_compl ) && empty( $groups_excl ) ) ? \Yii::t(
                                'catalog',
                                'Product must not be new and have categories with option groups'
                            ) : '',
                        ],
                    ],

                    [
                        'label'         => \Yii::t('catalog', 'Stock'),
                        'content'       => $this->render(
                            '_form_stock',
                            [
                                'form'         => $form,
                                'model'        => $model,
                                'modelLangs'   => $modelLangs,
                                'shops'        => $shops,
                            ]
                        ),
                        'headerOptions' => [
                            'class'               => ( !class_exists( '\artbox\stock\models\VariantToShop' ) ) ? 'disabled' : '',
                            'data-toggle'         => (!class_exists( '\artbox\stock\models\VariantToShop' ) ) ? 'tooltip' : '',
                            'data-placement'      => ( !class_exists( '\artbox\stock\models\VariantToShop' ) ) ? 'top' : '',
                            'data-original-title' => ( !class_exists( '\artbox\stock\models\VariantToShop' ) ) ? \Yii::t(
                                'catalog',
                                'You haven\'t this module'
                            ) : '',
                        ],
                    ],
                    
                ],
                'options' => [
                    'class' => 'bar_tabs',
                ],
            ]
        );
    ?>
    
    <div class="form-group">
        <?= Html::submitButton(
            $model->isNewRecord ? Yii::t('catalog', 'Create') : Yii::t('catalog', 'Update'),
            [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
        ) ?>
    </div>
    
    <?php ActiveForm::end(); ?>

</div>