<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="" method="post">

    <p>Родительская услуга</p>
    <div id="additional-information">
        <?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="checkbox" 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="checkbox" 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>

    <div class="additional-information">
        <div class="input-group">
            <span class="input-group-addon title-block-sizing">Вопрос</span>
            <input type="text" data-reg="name" class="form-control input-sizing validate-input"  name="sub_question_text">
        </div>

        <div class="input-group">
            <span class="input-group-addon title-block-sizing">Ключ</span>
            <input type="text" data-reg="name"  class="form-control input-sizing validate-input"  name="key">
        </div>

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


        <div class="input-group">
            <label><input type="checkbox"  data-оbligatory="true"  value="1"  name="sub_question_required">Обязательный</label>
        </div>
    </div>
    <p>
        <input type="submit" id="send-button" class="button_style" value="Добавить">
    </p>
</form>