Skip to content

Commit

Permalink
ADD: support for bulk options JetEngine field in select / radio / che…
Browse files Browse the repository at this point in the history
…ckbox field

Crocoblock/issues-tracker#7135
  • Loading branch information
girafffee committed Jul 30, 2024
1 parent 528c0da commit 46f569c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions compatibility/jet-engine/generators/get-from-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public function generate( $args ) {
}
}

if ( ! empty( $found_field ) && 'manual_bulk' === ( $found_field['options_source'] ?? '' ) ) {
return iterator_to_array(
$this->get_form_bulk_options( $found_field )
);
}

if ( empty( $found_field['options'] ) ) {
return $result;
}
Expand All @@ -75,4 +81,23 @@ public function generate( $args ) {
return $result;
}

private function get_form_bulk_options( array $field ): \Generator {
$options = $field['bulk_options'] ?? '';

if ( ! $options ) {
return;
}

$options = explode("\n", $options );

foreach ( $options as $option ) {
$parts = explode( '::', $option );

yield array(
'value' => $parts[0],
'label' => $parts[1] ?? $parts[0],
);
}
}

}

0 comments on commit 46f569c

Please sign in to comment.