default value on dynamically added form fields
Forms\Components\Group::make(
function (Get $get) {
$collection = $get('component.collection') ?? [];
return collect($collection)
->filter(function ($componentClass) {
// Ensure the component class is valid
return class_exists($componentClass);
})
->map(function ($componentClass, $key) {
// Dynamically resolve the component class and return its schema
return Forms\Components\Section::make($componentClass::$title)
->collapsible()
->schema($componentClass::getSchema($key)); // Show only if it's the current component
})
->toArray(); // Ensure it's an array of components
}
)->live()Forms\Components\Group::make(
function (Get $get) {
$collection = $get('component.collection') ?? [];
return collect($collection)
->filter(function ($componentClass) {
// Ensure the component class is valid
return class_exists($componentClass);
})
->map(function ($componentClass, $key) {
// Dynamically resolve the component class and return its schema
return Forms\Components\Section::make($componentClass::$title)
->collapsible()
->schema($componentClass::getSchema($key)); // Show only if it's the current component
})
->toArray(); // Ensure it's an array of components
}
)->live()And one of component classes have:
public static function getSchema (string $key): array
{
return [
Forms\Components\TextInput::make($key . '.title')
->default('Some default text')
->required()
];
}public static function getSchema (string $key): array
{
return [
Forms\Components\TextInput::make($key . '.title')
->default('Some default text')
->required()
];
}Some default text is not appearing.. Anyone know why? Thanks