<header>
    <nav class="navbar navbar-default navbar-static-top" role="navigation">
        <ul class="nav navbar-nav">
            <li><a href="/count_form.php/?p=admin">Услуги</a></li>
            <li><a href="/count_form.php/?p=sub_quest">Вопросы</a></li>
            <li><a href="http://seo.artweb.ua/count_form.php/">Выйти</a></li>
        </ul>
    </nav>
</header>
<h1>Добавить услугу</h1>
<form id = "send-form" data-url="" action="/count_form.php/?p=admin&sp=add" method="post">
    <div class="input-group">
        <span class="input-group-addon title-block-sizing">Услуга</span>
        <input type="text" data-reg="name" data-оbligatory="true" class="form-control input-sizing validate-input"  name="question_text">
    </div>

    <p>
        <label for="status">Инпут выбора</label>
        <select id="status" name="question_input_type">
            <option value="checkbox" selected>checkbox</option>
            <option value="radio">radio</option>
        </select>
    </p>

    <div class="input-group">
        <span class="input-group-addon title-block-sizing">Вес</span>
        <input type="text" data-reg="" data-оbligatory="true" class="form-control input-sizing validate-input" name="question_weight">
    </div>

    <div class="input-group">
        <label><input type="checkbox" data-оbligatory="true" value="1" checked name="question_status">Опубликован</label>
    </div>

    <div class="input-group">
        <label><input type="checkbox"  data-оbligatory="true"   value="1" name="question_required">Активный</label>
    </div>

    <h2>Родительская услуга</h2>
    <div id="roleList">
        <input type="radio" class="main-role" name="question_parent_id" value="0" checked>Нет
        <?php
        function showRole($array,$key){
        $num=count($array);
        for($i=0; $i<$num; $i++){
        if($array[$i]['parent_id']==$key){
        if($key == 0){?>
            <div><ul><li><label><input type="radio" class="main-role" name="question_parent_id" value="<?=$array[$i]['id']?>"><?=$array[$i]['text']?></label>
                        <?php
                        $key=$array[$i]['id'];
                        showRole($array,$key);
                        $key = $array[$i]['parent_id'];
                        ?>
                    </li>
                </ul>
            </div>
        <?php } else { ?>
        <ul >
            <li><label><input type="radio" name="question_parent_id" value="<?=$array[$i]['id']?>"><?=$array[$i]['text']?></label>
                <?php
                $key=$array[$i]['id'];
                showRole($array,$key);
                $key = $array[$i]['parent_id'];
                echo "</li>";
                echo "</ul>";
                }
                }
                }
                }
                $key=0;
                showRole($data['data'],$key);?>
    </div>
    <p>
        <input type="submit" id="send-button" class="button_style" value="Добавить">
    </p>
</form>
<script src="/count_form/js/validate.js"></script>