Closed brkfun closed 8 months ago
If this is a bug it is in Filament Core. The CreateAction is already calling ->getModelLabel()
internally to set the modal heading.
it cannot call for resources they are build from different class so thats why i added that line. You can also check out or i'll show an example if thats what you need.
I tried your pr and it had the same outcome. User was lowercase and not uppercase.
you need to add $modelLabel to your resource to change the title also. If you forgot that.
Let me show you an example :
class SimpleResource extends Resource
{
public static ?string $modelLabel = 'Your Header';
public static function form(Form $form): Form
{
// Your form goes here.
}
public static function getPages(): array
{
return [
'index' => ListPage::route('/'), // for make your resource simple if you add create or edit it directly goes to that route so we can open modal or slideover without give any more information to here.
];
}
}
after simple resource has been done you can directly call from your plugin with include.
->plugin(
QuickCreatePlugin::make()->includes([
SimpleResource::class,
])
)
and it will show the title as you change modelLabel
In "Model based resources" you can change your title as same way as this line i create.
That still doesn't make sense, the resource is still calling the same getModelLabel() in both cases. Internally on Filament's side it's still reading from the resource in the create action.
Yeah you are right. it doesn't make sense but it works because of action is no depended or extended by any type of page or any type of resource. But at the end it works like this and i can change the title.
in example create action goes for $this->$modelLabel
but in your package you are creating an action without calling modelLabel from resource.
What version of Filament are you on?
https://github.com/filamentphp/filament/blob/4d2528c67ead35c30df839b6e0c896722ef8a90f/packages/actions/src/CreateAction.php#L31 <- Filament uses $this->getModelLabel()
in the CreateAction class.
i'm** using 3.2.30 which is latest version i have the same line but, as i said you are creating the action from scratch it doesn't know the resources modelLabel because you are not passing it to that.
CreateAction
created by your package over menu it needs modelLabel you have to pass it from our resources to your created CreateAction.
I'll look into it some more when I get a chance. But it still doesn't sound right to have to explicitly set a label on the resource property for this to work.
Create action needs a header. Cause of null set over, it causes "model name"(ie. user instead of User) displays over modal and slideovers.