无法在updateOperation中添加按钮

huangapple go评论63阅读模式
英文:

Cannot add button in updateOperation

问题

I need some help.

我需要一些帮助。

I'm trying to add a "preview" button in the updateOperation, so I have the following content:

我想在updateOperation中添加一个“预览”按钮,所以我有以下内容:

public function setupUpdateOperation()
{
$this->crud->setUpdateContentClass('col-md-12');
$this->setupCreateOperation('update');
$this->crud->addButtonFromView('line', 'preview', 'preview', 'beginning');
}

but the button doesn't appear at all, I have also created the blade file within this directory: vendor/backpack/crud/buttons/preview.blade.php, which have this content:

但按钮根本不显示出来,我还在此目录中创建了blade文件:vendor/backpack/crud/buttons/preview.blade.php,它的内容如下:


Preview

Essentially, I need to add a button near "Annulla":

基本上,我需要在“Annulla”附近添加一个按钮:

英文:

I need some help.

I'm trying to add a "preview" button in the updateOperation, so I have the following content:

public function setupUpdateOperation()
{
    $this->crud->setUpdateContentClass('col-md-12');
    $this->setupCreateOperation('update');
    $this->crud->addButtonFromView('line', 'preview', 'preview', 'beginning');
}

but the button doesn't appear at all, I have also created the blade file within this directory: vendor/backpack/crud/buttons/preview.blade.php, which have this content:

<a href="/intranet/{{ $entry->slug }}?preview=1">
    <i class='fa fa-list'></i>Preview
</a>

Essentially, I need to add a button near "Annulla":

<img src="https://i.stack.imgur.com/nGafO.jpg">

答案1

得分: 1

没有内置的方法来在“取消”按钮之后添加按钮。但你可以:

(A) 在表单底部添加一个小部件,使用自定义的JavaScript将该按钮添加到右侧容器。你可以使用脚本小部件 来实现这一点,然后将小部件添加到after_content小部件部分,这是默认设置,所以会是这样的:

Widget::add()->type('script')->content('path/to/your/public/script.js');

(B) 将Backpack的form_save_buttons刀片文件发布到你的项目,然后在那里添加按钮。这将对所有表单和所有实体进行更改。但这也意味着你将不再从Backpack获得该文件的更新。你已经覆盖了它。你可以使用以下命令来执行此操作:

php artisan backpack:publish crud/inc/form_save_buttons

我强烈建议你选择选项A,因为它没有任何不利之处。

英文:

There is no built-in way to add buttons after the "Cancel" button. But you can:

(A) Add a widget at the bottom of the form, with your own custom JS, that adds that button to the right container. You can use the script widget for that, and you should push the widget to the after_content widget section, which is the default, so it will be:

Widget::add()-&gt;type(&#39;script&#39;)-&gt;content(&#39;path/to/your/public/script.js&#39;);

(B) Publish Backpack's form_save_buttons blade file to your project, and add that button there. That will make the change for ALL forms, for ALL entities. But this will also mean you no longer get updates for that file, from Backpack. You've overridden it. You can do that using:

php artisan backpack:publish crud/inc/form_save_buttons

I heavily recommend you do Option A, because that one doesn't have any downsides.

huangapple
  • 本文由 发表于 2023年2月24日 01:24:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定