<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,$data,$key){
        $num=count($array);
        for($i=0; $i<$num; $i++){
        if($array[$i]['parent_id']==$key){
        if($key == 0){?>
            <div><ul><li><label><input disabled type="checkbox" class="main-role"  <?= isset($data['question_id'])&&!empty($data['question_id'])&& $array[$i]['id'] == $data['question_id'] ? 'checked' : '' ?> name="question_parent_id[]" value="<?=$array[$i]['id']?>"><?=$array[$i]['text']?></label>
                        <?php
                        $key=$array[$i]['id'];
                        showRole($array,$data,$key);
                        $key = $array[$i]['parent_id'];
                        ?>
                    </li>
                </ul>
            </div>
        <?php } else { ?>
        <ul >
            <li><label><input disabled type="checkbox"  <?= isset($data['question_id'])&&!empty($data['question_id'])&& $array[$i]['id'] == $data['question_id'] ? 'checked' : '' ?> name="question_parent_id[]" value="<?=$array[$i]['id']?>"><?=$array[$i]['text']?></label>
                <?php
                $key=$array[$i]['id'];
                showRole($array,$data,$key);
                $key = $array[$i]['parent_id'];
                echo "</li>";
                echo "</ul>";
                }
                }
                }
                }
                $key=0;
                showRole($data['data'],$data['sub_question'], $key);?>
    </div>

    <div class="additional-information">
        <div class="input-group">
            <span class="input-group-addon title-block-sizing">Вопрос</span>
            <input type="text" data-оbligatory="true" class="form-control input-sizing validate-input"  value="<?= isset($data['sub_question']['text'])&&!empty($data['sub_question']['text']) ? $data['sub_question']['text'] : '' ?>" name="sub_question_text">
        </div>

        <div class="input-group">
            <span class="input-group-addon title-block-sizing">Ключ</span>
            <input type="text" value="<?= isset($data['sub_question']['key_num'])&&!empty($data['sub_question']['key_num']) ? $data['sub_question']['key_num'] : '' ?>" 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" <?= isset($data['sub_question']['input'])&&!empty($data['sub_question']['input'])&& $data['sub_question']['input'] == 'text' ? 'selected' : '' ?> >text</option>
                <option value="textarea" <?= isset($data['sub_question']['input'])&&!empty($data['sub_question']['input'])&& $data['sub_question']['input'] == 'textarea' ? 'selected' : '' ?>>textarea</option>
            </select>
        </p>


        <div class="input-group">
            <label><input type="checkbox" <?= isset($data['sub_question']['required'])&&!empty($data['sub_question']['required']) ? 'checked' : '' ?> 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>