首页 > 解决方案 > 自定义 Laravel Nova 破坏性动作模式

问题描述

我正在使用文档在 Laravel Nova 中定义一个新的破坏性动作,我想知道是否可以自定义模态消息,上面写着“你确定要运行这个动作吗”。

到目前为止,我所能做的就是通过执行以下操作将此消息替换为一个字段:

public function fields()
{
    return [
        Text::make('This is a test field')
    ];
}

但这会打开一个文本字段供用户填写。我怎样才能在此处仅输入文本,而无需用户输入字段?

标签: laravellaravel-nova

解决方案


根据 Laravel Nova发布说明,从 2.5.0 版本开始,您可以自定义动作模式的确认。

覆盖$confirmTextAction 类中的属性。

例如:

class YourAction extends Action
{
    /**
     * The text to be used for the action's confirmation text.
     *
     * @var string
     */
    public $confirmText = 'Your confirmation text?';
}

推荐阅读