<?php
$contentData = false;
if ($section) {
    $contentData = json_decode($section->content_data, true);
}
if (!$contentData || !isset($contentData['value'])) {
    $contentData = [
        'value' => '',
        'actionLog' => []
    ];
}
$formID = rand(0, 100000);

?>
<form method="POST" action="/process_form_submit">
    <?php if ($section) : ?>
        <input type="hidden" name="section_uid" value="<?= $section->uid ?>">
    <?php else : ?>
        <input type="hidden" name="note_uid" value="<?= $note->uid ?>">
        <input type="hidden" name="section_template_uid" value="<?= $sectionTemplate->uid ?>">
    <?php endif; ?>
    <div class="form-group mb-2">
        {{$contentData['value']}}
    </div>
    <div class="form-group m-0 d-flex">
        <input type="submit" value="INC" name="action" onclick="return doSubmit(this);">
        <input type="submit" value="DEC" name="action" onclick="return doSubmit(this);">
    </div>
</form>
<script>
    function doSubmit(_button) {
        var _form = $(_button).closest('form');
        var url = $(_form).attr('action');
        var action = $(_button).attr('value');
        console.log(action);
        showMask();
        var data = $(_form).serialize();
        data = data+'&action='+action;
        console.log(data);
        $.post(url, data, function(_data) {
            fastReload();
            return false;
        });
        return false;
    }
</script>