问题描述
我正在使用 documentation 在 Laravel Nova 中定义一个新的破坏性操作,我想知道是否可以自定义模态消息,其中显示“您确定要运行此操作吗”。
到目前为止,我所能做的就是通过执行以下操作用字段替换此消息:
public function fields()
{
return [
Text::make('This is a test field')
];
}
但这会显示一个文本字段供用户填写。我怎么能在这里只有文本,而没有用户输入字段?
解决方法
根据 Laravel Nova release notes,从 2.5.0 版本开始,您可以自定义操作模式的确认。
覆盖 Action 类中的 $confirmText
属性。
例如:
class YourAction extends Action
{
/**
* The text to be used for the action's confirmation text.
*
* @var string
*/
public $confirmText = 'Your confirmation text?';
}