Skip to content

Commit cdd3922

Browse files
authored
Allow collection option label to be a callback for dynamic child label (kristijanhusak#718)
1 parent d8c2ba6 commit cdd3922

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Kris/LaravelFormBuilder/Fields/CollectionType.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ protected function setupChild(FormField $field, $name, $value = null)
237237
['attr' => array_merge(['id' => $newFieldName], $this->getOption('attr'))]
238238
);
239239

240+
if (isset($firstFieldOptions['label'])) {
241+
$firstFieldOptions['label'] = value($firstFieldOptions['label'], $value, $field);
242+
}
243+
240244
$field->setName($newFieldName);
241245
$field->setOptions($firstFieldOptions);
242246

@@ -249,7 +253,6 @@ protected function setupChild(FormField $field, $name, $value = null)
249253

250254
$field->setValue($value);
251255

252-
253256
return $field;
254257
}
255258

0 commit comments

Comments
 (0)