<commit_before><?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\web\JsExpression;
/**
 * @var \common\db\ActiveRecord $model модель
 * @var \yii\web\View $this
 * @var string $id идентификатор виджета
 * @var array $formOptions параметры \yii\widgets\ActiveForm
 */

$perm = $model->getPermission();

$meta = $model->getMetaFields();

$tabId = "$id-tabs";

$this->registerJs("
    $('#{$tabId} a').click(function (e) {
        e.preventDefault()
        $(this).tab('show')
    })
");

?>

<? $form = ActiveForm::begin($formOptions); ?>

<? echo $form->errorSummary($model); ?>

    <ul id="<?= $tabId ?>" class="nav nav-tabs">
        <?
        $i = 0;
        foreach ($meta->tabs() AS $key => $title):?>
            <li <? if ($i == 0): ?>class="active"<? endif; ?>><a href="#<?= $key ?>"><?= $title ?></a></li>
            <?
            $i++;
        endforeach;?>
    </ul>

    <div class="tab-content">
        <?
        $i = 0;
        foreach ($meta->tabs() AS $key => $title): ?>
            <div class="<? if ($i == 0): ?>active <? endif; ?>tab-pane" id="<?= $key ?>">

                <? foreach ($meta->getFieldsByTab($key) AS $field):
                    if ($perm AND $perm->isAttributeForbidden($field->attr))
                        continue;
                    ?>
                    <?= $field->getWrappedForm($form); ?>
                <? endforeach; ?>

            </div>
            <?
            $i++;
        endforeach; ?>
    </div>


<?= Html::hiddenInput('apply', 0) ?>

<? $returnUrl = Yii::$app->request->get('returnUrl', Yii::$app->request->post('returnUrl', Yii::$app->request->referrer)); ?>

<?= Html::hiddenInput('returnUrl', $returnUrl) ?>

    <div class="form-group">
        <?= Html::submitButton(Yii::t('core', 'Save'), ['class' => 'btn btn-success']) ?>
        <?= Html::submitButton(Yii::t('core', 'Apply'), ['class' => 'btn btn-primary form-apply']) ?>
        <?= Html::button(Yii::t('core', 'Cancel'), ['class' => 'btn btn-default form-cancel']) ?>

    </div>

<?php
$this->registerJs("
	$('.form-apply').on('click', function(e){ $(\"input[name='apply']\").val(1);});
	$('.form-cancel').on('click', function(e){ e.preventDefault(); window.location.href='$returnUrl'; });
");
?>

<? ActiveForm::end(); ?><commit_msg>исправление ошибки яваскрипта<commit_after><?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\web\JsExpression;
/**
 * @var \common\db\ActiveRecord $model модель
 * @var \yii\web\View $this
 * @var string $id идентификатор виджета
 * @var array $formOptions параметры \yii\widgets\ActiveForm
 */

$perm = $model->getPermission();

$meta = $model->getMetaFields();

$tabId = "$id-tabs";

$this->registerJs("
    $('#{$tabId} a').click(function (e) {
        e.preventDefault()
        $(this).tab('show')
    });
");

?>

<? $form = ActiveForm::begin($formOptions); ?>

<? echo $form->errorSummary($model); ?>

    <ul id="<?= $tabId ?>" class="nav nav-tabs">
        <?
        $i = 0;
        foreach ($meta->tabs() AS $key => $title):?>
            <li <? if ($i == 0): ?>class="active"<? endif; ?>><a href="#<?= $key ?>"><?= $title ?></a></li>
            <?
            $i++;
        endforeach;?>
    </ul>

    <div class="tab-content">
        <?
        $i = 0;
        foreach ($meta->tabs() AS $key => $title): ?>
            <div class="<? if ($i == 0): ?>active <? endif; ?>tab-pane" id="<?= $key ?>">

                <? foreach ($meta->getFieldsByTab($key) AS $field):
                    if ($perm AND $perm->isAttributeForbidden($field->attr))
                        continue;
                    ?>
                    <?= $field->getWrappedForm($form); ?>
                <? endforeach; ?>

            </div>
            <?
            $i++;
        endforeach; ?>
    </div>


<?= Html::hiddenInput('apply', 0) ?>

<? $returnUrl = Yii::$app->request->get('returnUrl', Yii::$app->request->post('returnUrl', Yii::$app->request->referrer)); ?>

<?= Html::hiddenInput('returnUrl', $returnUrl) ?>

    <div class="form-group">
        <?= Html::submitButton(Yii::t('core', 'Save'), ['class' => 'btn btn-success']) ?>
        <?= Html::submitButton(Yii::t('core', 'Apply'), ['class' => 'btn btn-primary form-apply']) ?>
        <?= Html::button(Yii::t('core', 'Cancel'), ['class' => 'btn btn-default form-cancel']) ?>

    </div>

<?php
$this->registerJs("
	$('.form-apply').on('click', function(e){ $(\"input[name='apply']\").val(1);});
	$('.form-cancel').on('click', function(e){ e.preventDefault(); window.location.href='$returnUrl'; });
");
?>

<? ActiveForm::end(); ?>
{'fraction_non_alphanumeric': 0.24787442773054283, 'fraction_numerical': 0.002616088947024199, 'mean_word_length': 2.6499602227525854, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6627734', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1547, 'n_words': 278}