Skip to content

Commit

Permalink
Handle arrays of values with PodsUI when calling ui field method
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Sep 3, 2023
1 parent d335b3c commit 643f19e
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions classes/PodsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3991,18 +3991,29 @@ public function table( $reorder = false ) {
);
}
} else {
ob_start();
$row_value_is_array = is_array( $row_value );
$row_values = (array) $row_value;

$field_value = PodsForm::field_method( $attributes['type'], 'ui', $this->id, $row_value, $field, $attributes, $fields, $this->pod );
foreach ( $row_values as $row_value_key => $row_value_item ) {
ob_start();

$field_output = trim( (string) ob_get_clean() );
$field_value = PodsForm::field_method( $attributes['type'], 'ui', $this->id, $row_value_item, $field, $attributes, $fields, $this->pod );

if ( false === $field_value ) {
$row_value = '';
} elseif ( 0 < strlen( trim( (string) $field_value ) ) ) {
$row_value = trim( (string) $field_value );
} elseif ( 0 < strlen( $field_output ) ) {
$row_value = $field_output;
$field_output = trim( (string) ob_get_clean() );

if ( false === $field_value ) {
$row_values[ $row_value_key ] = '';
} elseif ( $field_value && 0 < strlen( trim( (string) $field_value ) ) ) {
$row_values[ $row_value_key ] = trim( (string) $field_value );
} elseif ( $field_output && 0 < strlen( $field_output ) ) {
$row_values[ $row_value_key ] = $field_output;
}
}

$row_value = $row_values;

if ( ! $row_value_is_array ) {
$row_value = $row_value ? current( $row_value ) : null;
}
}//end if

Expand Down

0 comments on commit 643f19e

Please sign in to comment.