Additional attributes in forms

To request more information from users on request creation and editing forms, you can add your own input fields and save the values in custom attributes.

For example, if you want to request a phone number, then create a custom attribute “Phone” in the support project and edit the request creation form (Administration - Settings - Texts) as follows

{% block content -%}
    <section class="card-section">
        <div class="container">
            <div class="col-lg-12 col-lg-offset-0">
                <div class="card text-center">
                    <div class="body">
                        {{ form_start(form, {"attr": {"class":"form-horizontal","action":path('issue_create')}}) }}
                            {{ form_widget(form) }}
                            <div class="control-group">
                                <div class="controls form-group">
                                    <div class="col-md-12">
                                        <input type="text" name="PhoneNumber" required class="search-field" placeholder="Phone" title="Specify your phone number">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                               <input type="submit" class="btn btn-success" value="{{ 'issue.create'|trans }}">
                            </div>
                        {{ form_end(form) }}
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

The name attribute of the input tag must match the reference (system) name of the user attribute in which the value entered by the user will be stored. The required attribute allows you to indicate that the attribute is required to be filled.

To put the attributes in a different order (Title, Phone and then the rest of the fields), implement the form as follows:

{% block content -%}
    <section class="card-section">
        <div class="container">
            <div class="col-lg-12 col-lg-offset-0">
                <div class="card text-center">
                    <div class="body">
                        {{ form_start(form, {"attr": {"class":"form-horizontal","action":path('issue_create')}}) }}
                            {{ form_row(form.caption) }}
                            <div class="control-group">
                                <div class="controls form-group">
                                    <div class="col-md-12">
                                        <input type="text" name="PhoneNumber" required class="search-field" placeholder="Phone" title="Phone number">
                                    </div>
                                </div>
                            </div>
                            {{ form_rest(form) }}
                            <div class="row">
                               <input type="submit" class="btn btn-success" value="{{ 'issue.create'|trans }}">
                            </div>
                        {{ form_end(form) }}
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

The request editing form is configured separately. Below is an example also using Phone Number:

{% block content -%}
    <section class="card-section">
        <div class="container">
            <div class="col-lg-12 col-lg-offset-0">
                <div class="card text-center">
                    <div class="body">
                        {{ form_start(edit_form, {'method':"PUT", "attr": {"class":"form-horizontal","action":path('issue_update', { 'id' : issue.id })}}) }}
                            {{ form_row(edit_form.caption) }}
                            <div class="control-group">
                                <div class="controls form-group">
                                    <div class="col-md-12">
                                        {% set value = showattribute(issue,'PhoneNumber') %}
                                        <input type="text" name="PhoneNumber" value="{{ value }}" required class="search-field" placeholder="Phone" title="Phone number">
                                    </div>
                                </div>
                            </div>
                            {{ form_rest(edit_form) }}
                            <div class="row">
                                <input type="submit" class="btn btn-success" value="{{ 'issue.update'|trans }}">
                            </div>
                        {{ form_end(edit_form) }}
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}