Create ForeignData
[phpmyadmin.git] / resources / templates / table / search / input_box.twig
blob4472bf88ae677e7cc9221aaa9ec2f63b8809440f
1 {# Get inputbox based on different column types (Foreign key, geometrical, enum) #}
2 {% if foreigners and search_column_in_foreigners %}
3     {% if foreign_data.dispRow is iterable %}
4         <select name="criteriaValues[{{ column_index }}]"
5             id="{{ column_id }}{{ column_index }}">
6             {{ foreign_dropdown|raw }}
7         </select>
8     {% elseif foreign_data.foreignLink %}
9         <input type="text"
10             id="{{ column_id }}{{ column_index }}"
11             name="criteriaValues[{{ column_index }}]"
12             id="field_{{ column_name_hash }}[{{ column_index }}]"
13             class="textfield"
14             {% if criteria_values[column_index] is defined %}
15                 value="{{ criteria_values[column_index] }}"
16             {% endif %}>
17         <a class="ajax browse_foreign" href="{{ url('/browse-foreigners') }}" data-post="
18             {{- get_common({'db': db, 'table': table}, '', false) -}}
19             &amp;field={{ column_name|url_encode }}&amp;fieldkey=
20             {{- column_index }}&amp;fromsearch=1">
21             {{ get_icon('b_browse', t('Browse foreign values')) }}
22         </a>
23     {% endif %}
24 {% elseif column_type in get_gis_datatypes() %}
25     <input type="text"
26         name="criteriaValues[{{ column_index }}]"
27         size="40"
28         class="textfield"
29         id="field_{{ column_index }}">
30     {% if in_fbs %}
31         <span class="open_search_gis_editor">
32             {{ link_or_button('#', null, get_icon('b_edit', t('Edit/Insert'))) }}
33         </span>
34     {% endif %}
35 {% elseif column_type starts with 'enum'
36     or (column_type starts with 'set' and in_zoom_search_edit) %}
37     {% set in_zoom_search_edit = false %}
38     {% set value = parse_enum_set_values(column_type) %}
39     {% set cnt_value = value|length %}
40     {#
41     Enum in edit mode   --> dropdown
42     Enum in search mode --> multiselect
43     Set in edit mode    --> multiselect
44     Set in search mode  --> input (skipped here, so the 'else' section would handle it)
45     #}
46     {% if (column_type starts with 'enum' and not in_zoom_search_edit)
47         or (column_type starts with 'set' and in_zoom_search_edit) %}
48         <select name="criteriaValues[{{ column_index }}]"
49             id="{{ column_id }}{{ column_index }}">
50     {% else %}
51         <select name="criteriaValues[{{ column_index }}]"
52             id="{{ column_id }}{{ column_index }}"
53             multiple="multiple"
54             size="{{ min(3, cnt_value) }}">
55     {% endif %}
56     {# Add select options #}
57     <option value=""></option>
58     {% for i in 0..cnt_value - 1 %}
59         {% if criteria_values[column_index] is defined
60             and criteria_values[column_index] is iterable
61             and value[i] in criteria_values[column_index] %}
62             <option value="{{ value[i]|raw }}" selected>
63                 {{ value[i]|raw }}
64             </option>
65         {% else %}
66             <option value="{{ value[i]|raw }}">
67                 {{ value[i]|raw }}
68             </option>
69         {% endif %}
70     {% endfor %}
71     </select>
72 {% else %}
73     {% set the_class = 'textfield' %}
74     {% if column_type == 'date' %}
75         {% set the_class = the_class ~ ' datefield' %}
76     {% elseif column_type == 'datetime' or column_type starts with 'timestamp' %}
77         {% set the_class = the_class ~ ' datetimefield' %}
78     {% elseif column_type starts with 'bit' %}
79         {% set the_class = the_class ~ ' bit' %}
80     {% endif %}
81     <input
82         {% if is_integer or is_float %}
83             type="number"
84             {% if is_integer %}
85                 inputmode="numeric"
86             {% else %}
87                 inputmode="decimal"
88             {% endif %}
89         {% else %}
90             type="text"
91         {%- endif %}
93         name="criteriaValues[{{ column_index }}]"
94         data-type="{{ column_data_type }}"
95         {{ html_attributes|raw }}
96         size="40"
97         class="{{ the_class }}"
98         id="{{ column_id }}{{ column_index }}"
99         {% if criteria_values[column_index] is defined %}
100            value="{{ criteria_values[column_index] }}"
101         {%- endif %}>
102 {% endif %}