Skip to content

Commit 6562196

Browse files
fix: update conditional elements
1 parent 8da5401 commit 6562196

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

classes/fields.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ public function render_all_input_types( $name, $data, $fields_type, $field_index
11081108

11091109
// conditional elements
11101110
$html_input .= '<div class="col-md-4 col-sm-4">';
1111-
$html_input .= '<select data-metatype="elements" class="ppom-conditional-keys form-control"></select>';
1111+
$html_input .= '<select name="ppom[' . esc_attr( $field_index ) . '][conditions][rules][0][elements]" class="ppom-conditional-keys form-control" data-metatype="elements"></select>';
11121112
$html_input .= '</div>';
11131113

11141114
// is

js/admin/ppom-admin.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,8 @@ jQuery( function ( $ ) {
22382238

22392239
$( document ).on( 'click', '.ppom-condition-tab-js', function ( e ) {
22402240
e.preventDefault();
2241-
populate_conditional_elements();
2241+
const id = $(this).parents('.ppom-tabs.ppom-fields-actions').data('field-no');
2242+
populate_conditional_elements(id);
22422243
} );
22432244

22442245
/**
@@ -2313,7 +2314,7 @@ jQuery( function ( $ ) {
23132314
* @see ppom_add_condition_set_index
23142315
* @see ppom_check_conditions in js/ppom-conditions-v2.js
23152316
*/
2316-
function populate_conditional_elements() {
2317+
function populate_conditional_elements(field_id) {
23172318
// Rebuild the list of condition targets from the current slider state so
23182319
// newly added, renamed, or cloned fields are immediately available as rule
23192320
// dependencies without reloading the admin page.
@@ -2344,10 +2345,7 @@ jQuery( function ( $ ) {
23442345
} );
23452346

23462347
// Change the target options for all the rules.
2347-
document.querySelectorAll( '.ppom-slider' ).forEach( ( item ) => {
2348-
if ( ! item.id ) {
2349-
return;
2350-
}
2348+
$('.ppom-slider#ppom_field_model_' + field_id ).each( ( index, item ) => {
23512349
const conditionContainers = item
23522350
.querySelector( 'div[data-meta-id="conditions"]' )
23532351
?.querySelectorAll( '.webcontact-rules' );

0 commit comments

Comments
 (0)