Php 我不知道';“得不到”;添加按钮";在双肩包Laravel上使用内嵌式创建
遵循本文件: 我尝试在发票(主要)和发票行(次要)之间创建链接。 这个链接看起来不错,但是我没有成功地使用第二个表单所需的“+添加”按钮。 我的密码 主类(invoiceCrudController)Php 我不知道';“得不到”;添加按钮";在双肩包Laravel上使用内嵌式创建,php,laravel,backpack-for-laravel,laravel-backpack,Php,Laravel,Backpack For Laravel,Laravel Backpack,遵循本文件: 我尝试在发票(主要)和发票行(次要)之间创建链接。 这个链接看起来不错,但是我没有成功地使用第二个表单所需的“+添加”按钮。 我的密码 主类(invoiceCrudController) 我认为你的定义是错误的: $this->crud->addFields([ /其他情况/ [ “名称”=>“发票行”, '类型'=>'关系', “标记”=>“发票行”, “ajax”=>正确, [//以单数形式指定实体 'entity'=>'invoiceLine',//单数形式的实体 ] ],
我认为你的定义是错误的:
$this->crud->addFields([
/其他情况/
[
“名称”=>“发票行”,
'类型'=>'关系',
“标记”=>“发票行”,
“ajax”=>正确,
[//以单数形式指定实体
'entity'=>'invoiceLine',//单数形式的实体
]
],
由于该关系与许多(我猜)有关,因此该文件应为:
[
'type' => "relationship",
'name' => 'invoiceLines',
'ajax' => true,
'inline_create' => true,
]
<?php
namespace App\Http\Controllers\Admin;
use App\Models\InvoiceLine;
use Backpack\CRUD\app\Http\Controllers\CrudController;
/**
* Class InvoiceCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class InvoiceLinesCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;
public function setup()
{
$this->setAccesses('invoiceLine');
$this->crud->setModel('App\Models\InvoiceLine');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/invoiceLine');
$this->crud->setEntityNameStrings('invoiceLine', 'invoiceLines');
$this->crud->addColumns([
[
'name' => 'slug',
'type' => 'text',
],
[
'name' => 'quantity',
'type' => 'number',
'default' => 1,
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
],
[
'name' =>'unit_vat_excluded',
'type' => 'text',
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
]
]);
}
protected function setupListOperation()
{
$this->crud->enableExportButtons();
CustomerCrudController::addFilterCustomer();
}
protected function setupCreateOperation()
{
$this->crud->addFields([
[
'name' => 'slug',
'type' => 'text',
'allows_null' => false,
],
[
'name' => 'quantity',
'type' => 'number',
'default' => 1,
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
],
[
'name' =>'unit_vat_excluded',
'type' => 'text',
'wrapper' => [
'class' => 'form-group col-sm-6 col-md-6 col-lg-3 col-xl-3'
]
]
]);
}
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
}
protected function setupShowOperation()
{
}
public static function getColumn()
{
return [
'name' => 'invoice_line_id',
'label' => 'InvoiceLines',
'type' => 'select',
'entity' => 'invoiceLine',
'attribute' => 'pretty_print',
'model' => InvoiceLine::class,
];
}
}
[
'type' => "relationship",
'name' => 'invoiceLines',
'ajax' => true,
'inline_create' => true,
]