Js字段操作在内联模态中

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

Js field manipulation in inline modal

问题

可以使用JavaScript来操作内联创建模态框中的字段吗?

我有几个类似的内联创建字段,例如:

CRUD::addField([
    'type' => "relationship",
    'name' => 'authors',
    'ajax' => true,
    'attribute' => 'fullName',
    'inline_create' => [
        'entity' => 'author',
    ] 
]);

我尝试使用 crud.field('authors').subfield('name') 但不起作用。

英文:

It is possible to manipulate fields in inline create modal with Javascript?

I have several inline create fields like that

CRUD::addField([
            'type' => "relationship",
            'name' => 'authors', 
            'ajax' => true,
            'attribute' => 'fullName',
            'inline_create' => [
                'entity' => 'author',
                ] 
        ]);

I tried using crud.field('authors').subfield('name') but doesn'r work

答案1

得分: 0

你需要使用 ->inline() 方法添加脚本小部件。

例如:

Widget::add()->type('script')->content('assets/js/products/inline-fields.js')->inline();

请注意,您需要在创建模态框内的相关CRUD的 setupCreateOperation 中添加此脚本。祝好运!

英文:

You need to add the script widget with ->inline().

For example:

Widget::add()->type('script')->content('assets/js/products/inline-fields.js')->inline();

Note that you need to add this script in the setupCreateOperation of the related crud you create inside the modal.

Cheers

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

发表评论

匿名网友

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

确定