Skip to content

Commit

Permalink
Include parent label on nested form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
doekenorg committed Jan 24, 2025
1 parent f3ecbd9 commit 46f6167
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ You can hide a row by adding a hook. Checkout this example:

* Enhancement: Nested forms can now also export entry meta values.
* Fixed: Nested form values could cause an exception.
* Fixed: Columns labels from Nested Form Fields no longer included the parent label.

= 2.3.7 on January 17, 2025 =

Expand Down
23 changes: 21 additions & 2 deletions src/Field/NestedFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,30 @@ public function getRows( ?array $entry = null ): iterable {
* @since 1.10
*/
protected function getSeparatedColumns(): array {
$fields = array_map( function ( FieldInterface $field ): array {
$columns = array_map( static function ( FieldInterface $field ): array {
return $field->getColumns();
}, array_values( $this->getNestedFields() ) );

return array_merge( [], ...$fields );
return array_map(
function ( $column ): string {
return
gf_apply_filters(
[
'gfexcel_field_label',
$this->field->get_input_type(),
$this->field->formId,
$this->field->id,
],
sprintf(
'%s (%s)', // Nested field label (Wrapper label)
(string) $column,
$this->getSubLabel( $this->field )
),
$this->field
);
},
array_merge( [], ...$columns )
);
}

/**
Expand Down

0 comments on commit 46f6167

Please sign in to comment.