nova-button
nova-button copied to clipboard
FR: Prompt option similar to action fields
Like the native javascript prompt
, it would be awesome to have this option, where you can supply any fields in a callback like action fields. If no callback is defined (or empty), a default text field should be provided.
Button::make('Cancel Account')
->prompt('Are you sure?', 'Please write CANCEL below to confirm', function () {
return [
Text::make('Confirm')->rules('required', 'in:CANCEL'),
Text::make('Reason'),
];
}),
Personally i think this would be waaay better:
Button::make('Cancel Account')
->ask('Are you sure?')
->cancel('Nope')
->confirm('Yes i do!')
->addFields(function() {
return [
Text::make('Reason'),
];
}),
Nice idea! Yeah I can definitely see the usefulness of being able to add fields for the button. It is almost like actions in that ability.
I was planning on adding action support to this package and this may overlap and provide identical functionality.
Button::make(‘Text’)->action(ActionWithFields::class),
I’m going to think on this a bit But thank you for pitching the idea :)
My problem with this is that vue portal is used in nova for each index row to render delete modals. Adding all this markup per row of a table seems irresponsible lol 25 rows with 25 action modals with 5 fields and of course not just text fields turns into ALOT
its a serious problem then
@dillingham
It's not possible to execute the action with javascript trigger ?
- Uncheck all checkbox
- Check the checkbox of that row
- Select the action and launch him ?
Button triggering an action would be useful on the Detail
page as well.
There would be no "flooding the markup" problem on the detail page.
Maybe that could be implemented first? 🙏