Skip to content

Commit

Permalink
Allow collection option label to be a callback for dynamic child label (
Browse files Browse the repository at this point in the history
  • Loading branch information
rudiedirkx authored Feb 12, 2024
1 parent d8c2ba6 commit cdd3922
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Kris/LaravelFormBuilder/Fields/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ protected function setupChild(FormField $field, $name, $value = null)
['attr' => array_merge(['id' => $newFieldName], $this->getOption('attr'))]
);

if (isset($firstFieldOptions['label'])) {
$firstFieldOptions['label'] = value($firstFieldOptions['label'], $value, $field);
}

$field->setName($newFieldName);
$field->setOptions($firstFieldOptions);

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

$field->setValue($value);


return $field;
}

Expand Down

0 comments on commit cdd3922

Please sign in to comment.