Skip to content

Commit 46f6167

Browse files
committed
Include parent label on nested form fields
1 parent f3ecbd9 commit 46f6167

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ You can hide a row by adding a hook. Checkout this example:
260260

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

264265
= 2.3.7 on January 17, 2025 =
265266

src/Field/NestedFormField.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,30 @@ public function getRows( ?array $entry = null ): iterable {
6969
* @since 1.10
7070
*/
7171
protected function getSeparatedColumns(): array {
72-
$fields = array_map( function ( FieldInterface $field ): array {
72+
$columns = array_map( static function ( FieldInterface $field ): array {
7373
return $field->getColumns();
7474
}, array_values( $this->getNestedFields() ) );
7575

76-
return array_merge( [], ...$fields );
76+
return array_map(
77+
function ( $column ): string {
78+
return
79+
gf_apply_filters(
80+
[
81+
'gfexcel_field_label',
82+
$this->field->get_input_type(),
83+
$this->field->formId,
84+
$this->field->id,
85+
],
86+
sprintf(
87+
'%s (%s)', // Nested field label (Wrapper label)
88+
(string) $column,
89+
$this->getSubLabel( $this->field )
90+
),
91+
$this->field
92+
);
93+
},
94+
array_merge( [], ...$columns )
95+
);
7796
}
7897

7998
/**

0 commit comments

Comments
 (0)