{# # --------------------------------------------------------------------- # # GLPI - Gestionnaire Libre de Parc Informatique # # http://glpi-project.org # # @copyright 2015-2025 Teclib' and contributors. # @licence https://www.gnu.org/licenses/gpl-3.0.html # # --------------------------------------------------------------------- # # LICENSE # # This file is part of GLPI. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # --------------------------------------------------------------------- #} {# @var form Glpi\Form #} {# @var question_types_manager Glpi\Form\QuestionType\QuestionTypesManager #} {# @var question_type Glpi\Form\QuestionType\QuestionTypeInterface #} {# @var question Glpi\Form\Question|null #} {# @var section Glpi\Form\Section|null #} {# @var can_update bool #} {# @var allow_unauthenticated_access bool #} {% import 'components/form/fields_macros.html.twig' as fields %} {% set base_field_options = { 'is_horizontal': false, 'full_width' : true, 'no_label' : true, } %}
{# Display question's title #}
{% if question is null %} {% set question_strategy = enum('Glpi\\Form\\Condition\\VisibilityStrategy').ALWAYS_VISIBLE %} {% else %} {% set question_strategy = question.getConfiguredVisibilityStrategy() %} {% endif %}
{# Validation dropdown #} {{ include('pages/admin/form/conditional_validation_dropdown.html.twig', { 'item': question, 'type': "Glpi\\Form\\Question", }, with_context = false) }} {# Visibility dropdown #} {{ include('pages/admin/form/conditional_visibility_dropdown.html.twig', { 'item': question, 'type': "Glpi\\Form\\Question", }, with_context = false) }} {# Duplicate question #} {# Delete question #} {# Extra actions #}
{# Display common fields #}
{{ fields.textareaField( 'description', question is not null ? question.fields.description : '', __('Description'), base_field_options|merge({ 'placeholder': __('Add a description'), 'aria_label': __("Question description"), 'enable_richtext': true, 'add_body_classes': ['content-editable-tinymce-editor', 'text-muted'], 'editor_height': "0", 'rows' : 1, 'toolbar_location': 'bottom', 'init': false, 'init_on_demand': question is not null ? true : false, 'mb': 'mb-0', }) ) }}
{# Render the specific question type #}
{{ question_type.renderAdministrationTemplate(question)|raw }}
{# Setup "glpi-loaded" attribute for questions, not for the template #} {% set base_attributes = question is null ? {} : {'glpi-loaded' : "false"} %}
{{ fields.dropdownArrayField( '_type_category', question_types_manager.getCategoryKey(question_type.getCategory()), question_types_manager.getCategoriesDropdownValues(), '', { 'init' : false, 'no_label' : true, 'mb' : '', 'field_class' : '', 'class' : 'form-select form-select-sm', 'width' : 'auto', 'dropdownCssClass' : 'question-type-dropdown-group-dropdown-select', 'aria_label' : __('Question type'), 'add_data_attributes' : { 'glpi-form-editor-on-change': 'change-question-type-category', }|merge(base_attributes), 'templateSelection' : question_types_manager.getTemplateSelectionForCategories(), 'templateResult' : question_types_manager.getTemplateResultForCategories(), } ) }} {% set types = question_types_manager.getQuestionTypesDropdownValuesForCategory(question_type.getCategory()) %} {{ fields.dropdownArrayField( 'type', get_class(question_type), types, question_type.getName(), { 'init' : false, 'no_label' : true, 'mb' : '', 'field_class' : types|length == 1 ? ' d-none' : '', 'class' : 'form-select form-select-sm', 'width' : 'auto', 'aria_label' : __('Question sub type'), 'add_data_attributes' : { 'glpi-form-editor-on-change' : 'change-question-type', 'glpi-form-editor-question-type-selector': '', }|merge(base_attributes), 'templateSelection' : question_types_manager.getTemplateSelectionForQuestionTypes(), 'templateResult' : question_types_manager.getTemplateResultForQuestionTypes(), } ) }} {% set sub_types = question_type.getSubTypes() %} {{ fields.dropdownArrayField( question_type.getSubTypeFieldName(), question_type.getSubTypeDefaultValue(question), question_type.getSubTypes(), '', { 'init' : false, 'no_label' : true, 'mb' : '', 'field_class' : sub_types is empty ? ' d-none' : '', 'class' : 'form-select form-select-sm', 'width' : 'auto', 'disabled' : sub_types is empty, 'aria_label' : question_type.getSubTypeFieldAriaLabel(), 'add_data_attributes' : { 'glpi-form-editor-on-change' : 'change-question-sub-type', 'glpi-form-editor-question-sub-type-selector' : '', 'glpi-form-editor-specific-question-extra-data': '', }|merge(base_attributes), } ) }}
{# Render the specific question options #}
{{ question_type.renderAdministrationOptionsTemplate(question)|raw }}
{# Common hidden data #}
{{ include('pages/admin/form/form_toolbar.html.twig', { 'can_update' : can_update, 'form' : form, 'vertical_layout': true }, with_context = false) }}