Skip to content

Commit

Permalink
Allow filter popup to use autocomplete with AJAX in PodsUI
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Mar 26, 2024
1 parent 078569b commit b9f4da6
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions classes/PodsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,15 @@ public function filters() {
foreach ( $filters as $filter ) {
$value = pods_v( 'filter_' . $filter );

// Only support the first item of the array.
if ( is_array( $value ) ) {
if ( empty( $value ) ) {
$value = null;
} else {
$value = current( $value );
}
}

if ( isset( $this->pod->fields[ $filter ] ) ) {
$filter_field = $this->pod->fields[ $filter ];

Expand Down Expand Up @@ -3407,6 +3416,12 @@ public function filters() {
public function filters_popup() {

$filters = $this->filters;

$pod = null;

if ( $this->pod ) {
$pod = $this->pod;
}
?>
<div id="pods-ui-posts-filter-popup" class="pods-hidden">
<form action="" method="get" class="pods-ui-posts-filter-popup">
Expand Down Expand Up @@ -3512,7 +3527,7 @@ public function filters_popup() {
'<span',
'</span>',
),
PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field )
PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field, $pod )
);
?>

Expand All @@ -3528,7 +3543,7 @@ public function filters_popup() {
'<span',
'</span>',
),
PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field )
PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field, $pod )
);
?>
</span>
Expand All @@ -3544,7 +3559,7 @@ public function filters_popup() {
$filter_field['default_value'] = '';

$filter_field['pick_format_type'] = 'single';
$filter_field['pick_format_single'] = 'dropdown';
$filter_field['pick_format_single'] = 'autocomplete';
$filter_field['pick_allow_add_new'] = 0;

$filter_field['input_helper'] = pods_v( 'ui_input_helper', pods_v( $filter, $this->fields['search'] ?: $this->fields['manage'], array(), true ), '', true );
Expand All @@ -3571,7 +3586,7 @@ public function filters_popup() {
'<span',
'</span>',
),
PodsForm::field( 'filter_' . $filter, $value, 'pick', $options )
PodsForm::field( 'filter_' . $filter, $value, 'pick', $options, $pod )
);
?>
</span>
Expand Down Expand Up @@ -3620,7 +3635,7 @@ public function filters_popup() {
'<span',
'</span>',
),
PodsForm::field( 'filter_' . $filter, $value, 'pick', $options )
PodsForm::field( 'filter_' . $filter, $value, 'pick', $options, $pod )
);
?>
</span>
Expand Down Expand Up @@ -3659,7 +3674,7 @@ public function filters_popup() {
'<span',
'</span>',
),
PodsForm::field( 'filter_' . $filter, $value, 'text', $options )
PodsForm::field( 'filter_' . $filter, $value, 'text', $options, $pod )
);
?>
</span>
Expand Down

0 comments on commit b9f4da6

Please sign in to comment.