Skip to content

Commit

Permalink
fix wpform datalist
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Foti <[email protected]>
  • Loading branch information
MocioF committed Jan 26, 2024
1 parent a6e38bd commit 95ab5e5
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions modules/comune/class-gcmi-wpforms-field-comune.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public function field_options( $field ): void {
$this->field_option( 'required', $field );

// Crea la select per il tipo di campo da creare.
$kind = isset( $field['kind'] ) ? $field['kind'] : 'tutti';
$tooltip = esc_html__( 'Choose which municipalities to show.', 'campi-moduli-italiani' );

$field_kind_label = $this->field_element(
Expand Down Expand Up @@ -218,7 +217,6 @@ public function field_options( $field ): void {
);

// Crea la scelta del filtro.
$filtername = isset( $field['filtername'] ) ? $field['filtername'] : '';
$tooltip = esc_html__( 'Leave empty for an unfiltered field, or digit a filtername to limit selectable municipalities.', 'campi-moduli-italiani' );
$field_filtername_label = $this->field_element(
'label',
Expand Down Expand Up @@ -257,30 +255,22 @@ public function field_options( $field ): void {
false
);

$field_filtername_datalist_open = '<datalist id="present_filternames">';
$field_filtername_datalist = '<datalist id="present_filternames">';

$filter_list = gcmi_get_list_filtri();
$arr_options = array_combine( $filter_list, $filter_list );
$options = array_combine( $filter_list, $filter_list );

$field_filtername_select = $this->field_element(
'select',
$field,
array(
'slug' => 'filtername',
'value' => ! empty( $field['filtername'] ) ? esc_attr( $field['filtername'] ) : '',
'options' => $arr_options,
),
false
);
$field_filtername_datalist_close = '</datalist>';
foreach ( $options as $arg_key => $arg_option ) {
$field_filtername_datalist .= sprintf( '<option value="%s">%s</option>', esc_attr( $arg_key ), $arg_option );
}
$field_filtername_datalist .= '</datalist>';

$this->field_element(
'row',
$field,
array(
'slug' => 'filter_type',
'content' => $field_filtername_label . $inline_css . $field_filtername_text .
$field_filtername_datalist_open . $field_filtername_select . $field_filtername_datalist_close,
'content' => $field_filtername_label . $inline_css . $field_filtername_text . $field_filtername_datalist,
)
);

Expand Down

0 comments on commit 95ab5e5

Please sign in to comment.