<?php

$items = array();
$x = null;
?>
<?=

$form->field($model, 'action')->dropDownList([
    ''=>'',
    'accept' => 'accept',
    'add-dst-to-address-list' => 'add-dst-to-address-list',
    'add-src-to-address-list' => 'add-src-to-address-list',
    'change-dscp' => 'change-dscp',
    'change-mss' => 'change-mss',
    'change-ttl' => 'change-ttl',
    'clear-df' => 'clear-df',
    'jump' => 'jump',
    'log' => 'log',
    'mark-connection' => 'mark-connection',
    'mark-packet' => 'mark-packet',
    'mark-routing' => 'mark-routing',
    'passthrough' => 'passthrough',
    'return' => 'return',
    'set-priority' => 'set-priority',
    'sniff-pc' => 'sniff-pc',
    'sniff-tzsp' => 'sniff-tzsp',
    'strip-ipv4-options' => 'strip-ipv4-options',
]);
?>
<?= $form->field($model, 'log_prefix')->label('Log Prefix'); ?>

<div id="addresslist">
    <?= $form->field($model, 'address_list')->label('Address List'); ?>
</div>

<div id="addresslisttimeout">
    <?= $form->field($model, 'address_list_timeout')->label('Timeout'); ?>
</div>

<div id="jumptarget">
    <?= $form->field($model, 'jump_target')->label('Jump Target'); ?>
</div>

<div id="dscp">
    <?= $form->field($model, 'new_dscp')->label('New DSCP'); ?>
</div>
<div id="mss">
    <?= $form->field($model, 'new_mss')->label('New TCP MSS'); ?>
</div>
<div id="ttl">
    <?= $form->field($model, 'new_ttl')->label('New TTL'); ?>
</div>
<div id="conmark">
    <?= $form->field($model, 'new_connection_mark')->label('New Connection Mark'); ?>
</div>
<div id="pacmark">
    <?= $form->field($model, 'new_packet_mark')->label('New Packet Mark'); ?>
</div>
<div id="routmark">
    <?= $form->field($model, 'new_routing_mark')->label('New Routing Mark'); ?>
</div>
<div id="priority">
    <?= $form->field($model, 'new_priority')->label('New Priority'); ?>
</div>
<?php
$script = <<< JS
    
    $(document).ready(function () {
       
    $.viewMap = {
            'accept': $([]),
            'add-dst-to-address-list': $('#addresslist, #addresslisttimeout'),
            'add-src-to-address-list': $('#addresslist, #addresslisttimeout'),
            'change-dscp': $('#dscp'),
            'change-mss': $('#mss'),
            'change-ttl': $('#ttl'),
            'clear-df' : $([]),
            'jump': $('#jumptarget'),
            'log' : $([]),
            'mark-connection': $('#conmark'),
            'mark-packet' :$('#pacmark'),
            'mark-routing' : $('#routmark'),
            'passthrough': $([]),
            'return' : $([]),
            'set-priority' : $('#priority'),
            'sniff-pc' : $([]),
            'sniff-tzsp' : $([]),
            'strip-ipv4-options' : $([]),

            
    };
         
            $('#mangle-action').change(function () {

    $.each($.viewMap, function () {
    $(this).hide();
    });
            $.viewMap[$(this).val()].show();
    });
       
    });
        
JS;
$this->registerJs($script, \yii\web\View::POS_END);
?>

