Hi,
I wanna use the InlineCreate operation and do some things on create and update methods.
When I have the request as argument :
public function store(StoreRequest $request){ ... }
I have this error :
Too few arguments to function App\\Http\\Controllers\\Admin\\OrderItemCrudController::store(), 0 passed
And when I remove request from argument, and use this in the method :
$this->crud->request->request->get('...')
I have this error :
Cannot access protected property Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanel::$request
Is there a way to get the request with the InlineCreate operation ?
Thanks for your help,
Ok my bad ! I see now that in Backpack 4.1.x we have to use :
$this->crud->getRequest()
So it's okay, sorry !
Still have a problem with the InlineCreate operation :
{message: "array_filter() expects parameter 1 to be array, null given", exception: "ErrorException",β¦}
exception: "ErrorException"
file: "/Users/kevinrignault/Documents/PROJECTS/bluto.local/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php"
line: 51
message: "array_filter() expects parameter 1 to be array, null given"
trace: [{function: "handleError", class: "Illuminate\Foundation\Bootstrap\HandleExceptions", type: "->"},β¦]
I have this error when I save from the modal !
Is it works with one to many relationship ?
The OrderItemCrudController :
class OrderItemCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
public function setup()
{
$this->crud->setModel('App\Models\OrderItem');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/orderitem');
$this->crud->setEntityNameStrings('an item', 'items');
}
protected function setupListOperation()
{
CRUD::setColumns([
['name' => 'product_name', 'label' => 'Product'],
['name' => 'product_price', 'label' => 'Unit price'],
['name' => 'qty', 'label' => 'Quantity']
]);
}
protected function setupCreateOperation()
{
$this->crud->setValidation(OrderItemRequest::class);
CRUD::addField([
'label' => "Product",
'type' => 'select2',
'name' => 'product_id', // the db column for the foreign key
'entity' => 'product', // the method that defines the relationship in your Model
'attribute' => 'name', // foreign key attribute that is shown to user
'model' => "App\Models\Product", // foreign key model
]);
CRUD::addField(['name' => 'qty', 'type' => 'text', 'label' => "Quantity"]);
}
}
The OrderCrudController :
class OrderCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\FetchOperation;
public function setup()
{
CRUD::setModel('App\Models\Order');
CRUD::setRoute(config('backpack.base.route_prefix') . '/order');
CRUD::setEntityNameStrings('an order', 'orders');
}
protected function setupListOperation()
{
CRUD::setColumns([
['name' => 'reference', 'label' => 'Reference'],
['name' => 'customer_name', 'label' => 'Customer'],
['name' => 'status', 'label' => 'Status'],
['name' => 'date_delivery', 'label' => 'Delivery'],
['name' => 'amount', 'label' => 'Amount']
]);
}
protected function setupCreateOperation()
{
$this->crud->setValidation(OrderRequest::class);
//-- Information
CRUD::addField([
'name' => 'col_info',
'type' => 'custom_html',
'value' => "<h3>Information</h3><hr>"
]);
CRUD::addField([
'name' => 'reference', 'type' => 'text', 'label' => "Reference",
'hint' => 'Automatic generation'
]);
CRUD::addField([
'name' => 'status',
'label' => 'Status',
'type' => 'select_from_array',
'options' => [
'IN_CREATION' => 'CREATION',
'NEW' => 'NEW',
'PROGRESS' => 'PROGRESS',
'DELIVERY' => 'DELIVERY',
'FINALIZED' => 'FINALIZED'
],
'allows_null' => false,
'default' => 'NEW'
]);
CRUD::addField([
'name' => 'date_delivery',
'type' => 'date_picker',
'label' => "Delivery date"
]);
CRUD::addField([
'label' => "Time Slot",
'type' => 'select2',
'name' => 'time_slot_id', // the db column for the foreign key
'entity' => 'timeSlot', // the method that defines the relationship in your Model
'attribute' => 'full_slot', // foreign key attribute that is shown to user
'model' => "App\Models\TimeSlot", // foreign key model
]);
CRUD::addField(['name' => 'amount', 'type' => 'text', 'label' => "Amount"]);
CRUD::addField(['name' => 'note', 'type' => 'textarea', 'label' => "Note"]);
/*CRUD::addField([
'label' => "Items",
'type' => 'select2_multiple',
'name' => 'items', // the method that defines the relationship in your Model
'entity' => 'items', // the method that defines the relationship in your Model
'attribute' => 'product_name', // foreign key attribute that is shown to user
'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
//'options' => (function ($query) {
// return $query->whereNotNull('parent_id')->get();
//})
]);*/
CRUD::addField([
'type' => "relationship",
'name' => 'items', // the method on your model that defines the relationship
'ajax' => true,
'inline_create' => [ 'entity' => 'orderitem' ]
]);
//-- Customer
CRUD::addField([
'name' => 'col_customer',
'type' => 'custom_html',
'value' => "<br><h3>Customer</h3><hr>"
]);
CRUD::addField([
'label' => "Customer",
'type' => 'select2',
'name' => 'customer_id', // the db column for the foreign key
'entity' => 'customer', // the method that defines the relationship in your Model
'attribute' => 'name', // foreign key attribute that is shown to user
'model' => "App\User", // foreign key model
'options' => (function ($query) {
return $query->whereHas('roles', function($q){
$q->where('name', 'customer');
})->get();
}),
]);
}
}
The OrderItem model :
class OrderItem extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'order_items';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $fillable = [];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function order()
{
return $this->belongsTo('\App\Models\Order', 'order_id');
}
public function product()
{
return $this->belongsTo('\App\Models\Product', 'product_id');
}
public function supplier()
{
return $this->belongsTo('\App\Models\Supplier', 'supplier_id');
}
}
The Order model :
class Order extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'orders';
// protected $primaryKey = 'id';
// public $timestamps = false;
protected $guarded = ['id'];
// protected $fillable = [];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function items()
{
return $this->hasMany('\App\Models\OrderItem');
}
public function customer()
{
return $this->belongsTo('\App\User');
}
public function timeSlot()
{
return $this->belongsTo('\App\Models\TimeSlot');
}
}
PS : I updated my project from Backpack 4.0 to 4.1
Thanks
It should work just fine with 1-n relationships, yes. But from what I see - your problem is with SaveActions.php which is weird because afaik we're not using SaveActions inside the InlineCreate modal. @pxpm what do you think might be the problem?
Hum ... I don't think it's possible for them to relate.
We just call create() that has nothing with save actions on it.
If this stills a bug please re-open. I really don't think this is reproducible.
Hey there, I'm having the exact same issue. array_filter() expects parameter 1 to be array, null given {"exception":"[object] (ErrorException(code: 0): array_filter() expects parameter 1 to be array, null given at /var/www/local.at20skladiste/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php:51) Any news on this??
I'm just commenting to say that I am having the same issue with n-n inline create
hello @zachweix could you provide me the output of php artisan backpack:version and also the full stack or atleast the previous error in stack ? I mean, you get the array_filter error but there is somethings that previously calls: getSaveActionByOrder(). Can you provide me more error detail ?
I am going to re-open this as so many have the same error, I just could not reproduce it.
It's something I am doing wrong or something is missing.
By any chance you are removing/manipulating the save actions in the crud you create inline or in the main crud?
The error is triggered because $this->getOperationSetting('save_actions') is not returning an array even if empty, is returning null.
We setup 3 save actions by default, even if we don't use it in the inline modal (we just use save and cancel), when we get the inline modal we build a full CrudPanel for the inlined crud.
I can't think when will $this->getOperationSetting('save_actions') be null. Event when you$this->crud->removeAllSaveActions() we set it up as an empty array.
public function removeAllSaveActions()
{
$this->setOperationSetting('save_actions', []);
}
We use inline create in demo for example, and it works. That's why something must be different.
Thanks for understanding and sorry for this bad experience.
Might it be because people are renaming functions that we use in inline create ?
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
And I don't see them setup in the controller. Altough it does not relate to save actions, as the crud does not build correctly that might be the first error that is triggered.
Best,
Pedro
[2020-09-01 19:31:38] local.ERROR: array_filter() expects parameter 1 to be array, null given {"userId":97303,"exception":"[object] (ErrorException(code: 0): array_filter() expects parameter 1 to be array, null given at /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php:51)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'array_filter() ...', '/home/vagrant/c...', 51, Array)
#1 /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php(51): array_filter(NULL, Object(Closure))
#2 /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php(28): Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanel->getSaveActionByOrder(1)
#3 /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php(307): Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanel->getFallBackSaveAction()
#4 /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Http/Controllers/Operations/CreateOperation.php(86): Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanel->setSaveAction()
#5 /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Http/Controllers/Operations/InlineCreateOperation.php(78): App\\Http\\Controllers\\Admin\\ContentTagCrudController->store()
#6 [internal function]: App\\Http\\Controllers\\Admin\\ContentTagCrudController->storeInlineCreate()
#7 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#8 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('storeInlineCrea...', Array)
#9 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\Admin\\ContentTagCrudController), 'storeInlineCrea...')
#10 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\\Routing\\Route->runController()
#11 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\\Routing\\Route->run()
#12 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#13 /home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Http/Controllers/CrudController.php(43): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(153): Backpack\\CRUD\\app\\Http\\Controllers\\CrudController->Backpack\\CRUD\\app\\Http\\Controllers\\{closure}(Object(Illuminate\\Http\\Request), Object(Closure))
#15 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /home/vagrant/code/healthmeans-laravel/app/Http/Middleware/CheckIfAdmin.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): App\\Http\\Middleware\\CheckIfAdmin->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(76): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#33 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#34 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#35 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#36 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#37 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#38 /home/vagrant/code/healthmeans-laravel/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#40 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#41 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#42 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#46 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#47 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 /home/vagrant/code/healthmeans-laravel/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#50 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#51 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#52 /home/vagrant/code/healthmeans-laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#53 /home/vagrant/code/healthmeans-laravel/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#54 {main}
"}
// This is the Main Crud Controller that has the relationship field in it.
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\GroupRequest;
use App\Models\SiteSetting;
use App\Services\UtilityService;
use App\Http\Traits\AccessControl;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\CrudPanel;
/**
* Class GroupCrudController.
* @property-read CrudPanel $crud
*/
class GroupCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\FetchOperation;
use AccessControl;
public function setup()
{
/*
|--------------------------------------------------------------------------
| CrudPanel Basic Information
|--------------------------------------------------------------------------
*/
$this->crud->setModel(\App\Models\Group::class);
$this->crud->setRoute(config('backpack.base.route_prefix').'/group');
$this->crud->setEntityNameStrings('group', 'groups');
$this->crud->orderBy('title');
$this->crud->operation(['create', 'update'], function () {
$this->setupFields();
});
// a trait used across CRUD controllers to disable features based on a user's permissions
$this->updateAccessControls();
}
public function fetchTags()
{
return $this->fetch(\App\Models\ContentTag::class);
}
protected function setupListOperation()
{
$this->crud->setDefaultPageLength(100);
$this->crud->addFilter([
'type' => 'simple',
'name' => 'premium_content',
'label'=> 'Available for Purchase',
],
false,
function () { // if the filter is active
$this->crud->addClause('where', 'premium_content', '=', true);
});
$this->crud->addColumns([
'title',
[
'name' => 'Available for Purchase',
'type' => 'closure',
'function' => function ($entry) {
if ($entry->premium_content) {
return '<i class="la la-check"></i>';
} else {
return '';
}
},
],
]);
}
public function store()
{
$this->crud->setValidation(GroupRequest::class);
$response = $this->traitStore();
$id = $this->crud->entry->id;
// LINE TAKEN OUT //
$this->crud->entry->short_url = $data->shorturl;
$this->crud->entry->save();
UtilityService::clearCache();
return $response;
}
public function update()
{
if (!backpack_user()->isGivenPermissionTo('update')) {
return abort(403);
}
//$this->crud->setValidation(GroupRequest::class);
$request = $this->crud->getRequest();
//$id = \Route::current()->parameter('id');
/*
if($request['short_url'] == '' || $request['short_url'] == null){
/// LINE TAKEN OUT ///
$request['short_url'] = $data->shorturl;
}
*/
$response = $this->traitUpdate();
UtilityService::clearCache();
return $response;
}
public function setupFields()
{
$tab1 = 'General Info';
$tab2 = 'Talks';
$tab3 = 'Access';
$tab4 = 'Content Providers';
$default_group_cost = SiteSetting::where('key', 'global_cost_of_group')->first();
$this->crud->addField(
[
'name' => 'cover_photo_url',
'label' => 'Cover Photo',
'type' => 'image',
'upload' => true,
'tab' => $tab1,
'disk' => 's3',
]
);
$this->crud->addField(
[
'name' => 'background_photo_url',
'label' => 'Background Photo',
'type' => 'image',
'upload' => true,
'tab' => $tab1,
'disk' => 's3',
]
);
$this->crud->addField([
'name' => 'legacy_id',
'type' => 'text',
'attributes' => ['disabled' => 'disabled'],
'tab' => $tab1,
'wrapper' => [
'class' => 'form-group col-lg-6',
],
]);
$this->crud->addField([
'name' => 'title',
'tab' => $tab1,
'wrapper' => [
'class' => 'form-group col-lg-6',
],
]);
$this->crud->addField([
'name' => 'short_url',
'attributes' => ['disabled' => 'disabled'],
'tab' => $tab1,
'wrapper' => [
'class' => 'form-group col-lg-6',
],
]);
$this->crud->addField([
'name' => 'description',
'type' => 'ckeditor',
'tab' => $tab1,
]);
$this->crud->addField([
'name' => 'short_description',
'type' => 'ckeditor',
'maxCharCount' => 200,
'tab' => $tab1,
]);
$this->crud->addField([
'name' => 'advert_id',
'label' => 'Advertisment ID',
'tab' => $tab1,
]);
$this->crud->addField(
[
'label' => 'Content Tags',
'name' => 'content_tags',
'type' => "relationship",
'model' => "App\Models\ContentTag",
'ajax' => true,
'attribute' => 'label',
'entity' => 'content_tags',
'inline_create' => [ 'entity' => 'content_tag'],
'tab' => $tab1,
'data_source' => url("admin/group/fetch/tags"),
],
);
$this->crud->addField([
'name' => 'affiliate_id',
'tab' => $tab1,
]);
$this->crud->addField([
'name' => 'hide_speakers',
'label' => 'Hide Content Providers',
'type' => 'checkbox',
'tab' => $tab1,
]);
$this->crud->addField([
'name' => 'hide_media_attachments',
'label' => 'Hide Downloadable Content (Pdfs, etc.)',
'type' => 'checkbox',
'tab' => $tab1,
]);
$this->crud->addField([
'name' => 'hide_auto_generated',
'label' => 'Hide Auto-Generated Content? (Audio/Video)',
'type' => 'checkbox',
'tab' => $tab1,
]);
//TALKS TAB FIELDS
$this->crud->addField([
'name' => 'talk list',
'title' => 'Talks',
'type' => 'talk_list',
'api_url' => '/admin/api/group/'.\Route::current()->parameter('id').'/talks',
'tab' => $tab2,
]);
$this->crud->addField(
[
'name' => 'premium_content',
'label' => 'Available for Purchase',
'type' => 'checkbox',
'tab' => $tab3,
'wrapper' => [
'style' => 'margin-bottom:0px;',
],
]
);
$this->crud->addField(
[
'name' => 'premium_cost',
'label' => '',
'hint' => 'If no cost is entered and <strong>Available for Purchase</strong> is checked the default cost of $'.$default_group_cost->value.' will be used.',
'type' => 'number',
'attributes' => ['step' => '0.01', 'placeholder'=> $default_group_cost->value],
'wrapper' => [
'class' => 'no-label form-group col-sm-12',
'style' => 'margin-bottom:0px;',
],
'tab' => $tab3,
]
);
$this->crud->addField([
'name' => 'separator_two',
'type'=>'custom_html',
'value' => '<hr>',
'tab' => $tab3,
'wrapper' => [
'style' => 'margin-bottom:0px;',
],
]);
$this->crud->addField(
[
'name' => 'premium_live_date',
'label' => 'Visibility Date',
'type' => 'date_picker',
'tab' => $tab3,
'hint' => 'This field sets when a group will be visible to end-users. NOTE: This does not apply to users with a Pro Membership.',
'date_picker_options' => [
'format' => 'mm/dd/yyyy',
'language' => 'en',
],
'wrapper' => [
'style' => 'margin-bottom:0px;',
],
]
);
$this->crud->addField(
[
'name' => 'speaker_list',
'type' => 'view',
'view' => 'speakerList',
'tab' => $tab4,
]
);
// add asterisk for fields that are required in GroupRequest
$this->crud->setRequiredFields(GroupRequest::class, 'create');
$this->crud->setRequiredFields(GroupRequest::class, 'edit');
}
}
This is the controller for the item I'm trying to create inline.
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use App\Http\Requests\ContentTagCrudRequest;
class ContentTagCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
public function setup()
{
$this->crud->setModel("App\Models\ContentTag");
$this->crud->setRoute(config('backpack.base.route_prefix').'/content_tag');
$this->crud->setEntityNameStrings('content tag', 'content tags');
}
public function setupListOperation()
{
$this->crud->setColumns(['label']);
}
public function setupCreateOperation()
{
$this->crud->setValidation(ContentTagCrudRequest::class);
$this->crud->addField([
'name' => 'label',
'type' => 'text',
'label' => "Label"
]);
}
public function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}
The content tag that I am trying to create gets created successfully. It just doesn't send it down to the relationship field and / or update the parent model I'm trying to attach the tag to.
Any kind of update on this?? This is a pretty necessary feature.
I'm using this in another controller now and per the comment by @pxpm I'm not using custom names for the controllers. I'm still seeing the same problem.
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\HTOOfferSegmentRequest;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
use App\Http\Traits\AccessControl;
/**
* Class HTOOfferSegmentCrudController
* @package App\Http\Controllers\Admin
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
*/
class HTOSegmentCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\FetchOperation;
use AccessControl;
public function setup()
{
$this->crud->setModel('App\Models\HTOSegment');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/hto/segment');
$this->crud->setEntityNameStrings('Segment', 'Segments');
$this->crud->operation(['create', 'update'], function () {
$this->setupFields();
});
// a trait used across CRUD controllers to disable features based on a user's permissions
$this->updateAccessControls();
}
public function fetchTags()
{
return $this->fetch(\App\Models\ContentTag::class);
}
protected function setupListOperation()
{
// TODO: remove setFromDb() and manually define Columns, maybe Filters
$this->crud->addColumns(['name']);
}
protected function setupFields()
{
// TODO: remove setFromDb() and manually define Fields
$this->crud->addField([
'label' => 'Name',
'name' => 'name'
]);
$this->crud->addField(
[
'label' => 'Content Tags',
'name' => 'content_tags',
'type' => "relationship",
'model' => "App\Models\ContentTag",
'ajax' => true,
'attribute' => 'label',
'entity' => 'content_tags',
'inline_create' => [ 'entity' => 'content_tag'],
'data_source' => url("admin/hto/segment/fetch/tags"),
],
);
}
}
Hello @selected-pixel-jameson
Can you please test #3196 and let us know if it fixed in your scenario ? Read the business rules in the PR thread.
Thanks,
Pedro
@pxpm Thank you for the response. I'm not sure if I did this right or not, but I overrode the files in the vendor/backpack/src/ folder with the file sin the PR. After updating those files I attempted to create a new tag via the inline 'Add' function and received the same error.
ATM when testing a PR that is something you could do, just keep in mind that any changes that you do on vendor folder will be overridden when you 'composer update'.
Unfortunately if you get the same error I think the previous PR will not fix it.
I will keep digging because as of now I am not able to reproduce that error.
I am on it, we will eventually get to fix it sooner than later. Thanks for the time spent giving us info and testing stuff. We really appreciate it.
I will come back here as soon as I found why the hell that save action error is triggering with inline create.
Best,
Pedro
Here are the migrations I have for the data structures.
Schema::create('content_tags', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('label')->unique();
$table->timestamps();
});
Join Tables
Schema::create('talk_content_tag', function (Blueprint $table) {
$table->bigInteger('content_tag_id')->unsigned();
$table->integer('talk_id')->unsigned();
$table->integer('weight')->unsigned()->default(0);
$table->integer('type')->unsigned()->default(0); //0 Content //1 Transcript
$table->primary(['content_tag_id', 'talk_id'], "content_tag_id_talk_id");
$table->foreign('content_tag_id')->references('id')->on('content_tags');
$table->foreign('talk_id')->references('id')->on('talks');
$table->timestamps();
});
Schema::create('group_content_tag', function (Blueprint $table) {
$table->bigInteger('content_tag_id')->unsigned();
$table->integer('group_id')->unsigned();
$table->integer('weight')->unsigned()->default(0);
$table->primary(['content_tag_id', 'group_id'], "content_tag_id_group_id");
$table->foreign('content_tag_id')->references('id')->on('content_tags');
$table->foreign('group_id')->references('id')->on('groups');
$table->timestamps();
});
This is how I'm defining the relationship for the model used on GroupCrudController.
public function content_tags()
{
return $this->belongsToMany(\App\Models\ContentTag::class, 'group_content_tag', 'group_id', 'content_tag_id')->withPivot('weight')->orderBy('weight', 'DESC');
}
Really would like to get this implemented as it's in production software right now and the clients can't use it.
Do you happen to have a dev stage that you could give me access ? What is the exact BP version you are using ? php artisan backpack:version
If you happen to have a dev stage that you could let me access my email is on my github profile to send details.
Working on the PR I linked to you today I did setup M-M relationship with Inline Create and I got no errors. There must be something different, I might happen that is not something 'directly' connected with InlineCreate but with some other part of the software that causes InlineCreate to fail.
Is my best wish to find the culprit and fix it, just can't found it yet :| so sorry.
Best,
Pedro
PHP 7.3.15-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 23 2020 07:23:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.15, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.15-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
v6.18.38@94a29cadcc0d48b89b4aa820f414fb7721ba0e22
4.1.21@187bb0c3ce52ac2bfefeb9cd7518fec27a82ebcc
Give me a second on the development environment...
Are you referring to the admin site or are you saying you want access to the actual code??
I would need access to the code, not the admin area. Well, technically both would work better so I can try to debug what you have different from me that InlineCreate is broken for your M-M and not mine :) You can setup something with only those controllers/models etc so I can test it, no need for full application.
This is not something that I usually do, but since InlineCreate is one of my babies, and a very cool feature (I think atleast), I want it to be working like a breeze, and this issue opened is bothering me for a while and I am eager to close it ASAP.
Thank you very much,
Pedro
I can't give you access to the code. This is a commercial project. I appreciate your support, but I can't spend hours helping you fix this issue.
I deleted the admin account I setup for you since it's not what you were looking for.
I understand. I will try replicate from the information you gave. It would be easier for me, but I will try and get back to you with the findings.
Btw, I didn't login.
Wish you the best,
Pedro
Well this is weird. I can't replicate the error either.
Ok... so let's see what we can do about this - it'll be a tricky one, since it's a blind fix.
getSaveActionByOrder() method directly?@selected-pixel-jameson , what if you make this small change inside your SaveActions.php?
public function getSaveActionByOrder($order)
{
- return array_filter($this->getOperationSetting('save_actions'), function ($arr) use ($order) {
+ return array_filter($this->getOperationSetting('save_actions') ?? [], function ($arr) use ($order) {
return $arr['order'] == $order;
});
}
If the actual saving works, and the only problem is that getOperationSetting('save_actions') returns null instead of [], this should fix that particular problem. We still don't know _how_ it got to be null, but at least it'll work when _it is_ null.
Alternatively, instead of editing the files in your vendor folder, you can do composer require backpack/crud:"dev-fix-2708 as 4.1.99" to use the branch that contains the fix above. You can then revert using composer require backpack/crud:"4.1.*"
The error trace might provide extra information that we missed in the dump you provided above.

Maybe that'll provide some additional insight in what we're doing differently than you, when testing.
Sorry this takes so much back-and-forth to solve. But without being able to replicate it ourselves, the only way to solve it for you is to ask you to try stuff. I'm pretty confident the fix I proposed above will fix this though. I'm just wondering if there won't be something else that fails afterwards, since we're not fixing _the problem_, just its result.
Cheers!
Thank you,
Where is the SaveActions.php file located?
The error that is returned is not returned via Flare.IO. Itβs returned via the HTTP response since the call to save the new tag to the parent content is made via javascript.
The error that is returned is not returned via Flare.IO. Itβs returned via the HTTP response since the call to save the new tag to the parent content is made via javascript.
Ah, damn it...
Where is the SaveActions.php file located?
It's in vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php
You should be able to see a cleaner diff here - https://github.com/Laravel-Backpack/CRUD/pull/3209/files
Well, we have some progress.
When I updated the SaveAction.php file I started receiving a different error.
{
"message": "Undefined variable: redirectUrl",
"exception": "ErrorException",
"file": "/home/vagrant/code/healthmeans-laravel/vendor/backpack/crud/src/app/Library/CrudPanel/Traits/SaveActions.php",
"line": 354,
"trace": [
// ....
]
}
I also started to work on this fix, but before sending the PR my head said to me: "Cristian will never accept this fix without knowing the underlaying problem".
This is like when people have the yellow warning lights in the car display and need to go to inspection, they know it will not be approved so they just say to the mechanic to "turn them off for a while so I can be approved in car inspection" without actually fixing the error.
I am not saying there is no error here, but just "turning off the lights to pass the inspection" is not a good way to go.
The above error is because we are performing save actions without any action there.
My recomendation is to update the @tabacitu code to:
if(is_null($this->getOperationSetting('save_actions'))) {
$this->setupDefaultSaveActions();
}
return array_filter($this->getOperationSetting('save_actions'), function ($arr) use ($order) {
return $arr['order'] == $order;
});
I don't agree with this, something might need a better fix than this, but anyway, this should get you going.
Best,
Pedro
This did in fact fix the issue.
Can I overwrite this file outside of the vendor files? Committing the Vendor files to the repo is not an option.
Somehow, somewhat, somewhere your setup is not calling the setup default save actions. This is the problem
Because like I discussed with @tabacitu in my attemps to reproduce this, I have, indeed the save actions in the inline controller, because we init all the controller defaults, plus the create operation so we can get the fields.
Could this be related to your "permissions check" in controller that prevents the controller from building correctly?
This file is internal and can't be overriden outside of vendor folder. But don't rush into do this, it's a bad pratice and could get you troubles in future. It's my advice, but ofc you are free to do wtv your desire is.
Thanks for the time spent helping us in debbuging this.
Best,
Pedro
I have remove the AccessControl Trait and the call to $this->updateAccessControls(); and I still receive the same error.
We are using the permission manager and Iβm wondering if that has something to do with it.
@selected-pixel-jameson sorry, you can't - it's inside the package so it needs a fix at that level.
@pxpm totally agree with you - I wouldn't agree with a fix like that π because as you see, it just generates another error, without fixing the underlying problem. Who knows how many errors need to be fixed going downstream. It's better to go upstream and fix the underlying issue. And I totally agree with your assessment - that should be the root cause.
So let's break it down. InlineCreate _does_ call the SaveActions, that's how the item gets saved when $this->store() gets called inside InlineCreateOperation::storeInlineCreate(). So SaveActions are important inside InlineCreate.
But for some reason, in this case, the save actions aren't there when InlineCreateOperation::storeInlineCreate() gets called. Either:
InlineCreate, not create)My money is on (C). Let's see. @selected-pixel-jameson , what if - instead of any of the changes above in vendor, you just add this green line in your project's ContentTagCrudController?
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use App\Http\Requests\ContentTagCrudRequest;
class ContentTagCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
public function setup()
{
$this->crud->setModel("App\Models\ContentTag");
$this->crud->setRoute(config('backpack.base.route_prefix').'/content_tag');
$this->crud->setEntityNameStrings('content tag', 'content tags');
}
public function setupListOperation()
{
$this->crud->setColumns(['label']);
}
public function setupCreateOperation()
{
+ $this->crud->setupDefaultSaveActions();
$this->crud->setValidation(ContentTagCrudRequest::class);
$this->crud->addField([
'name' => 'label',
'type' => 'text',
'label' => "Label"
]);
}
public function setupUpdateOperation()
{
$this->setupCreateOperation();
}
}
This fixes the problem!!
Awesome π₯³ Hopefully that's a good fix for you, for the time being.
Ideally though, we'd need to understand _why_ in your project it does that, and in our tests it does not. Especially since you're not the only one - other people have reported the same thing.
So far we've narrowed it down to this line inside InlineCreateOperation's setup. What it does is that it runs the _exact PHP lines_ from CreateOperation, so that it's set up exactly the same. That includes the default SaveActions. But for some reason, for you, it doesn't do that...
The fix above just manually calls $this->crud->setupDefaultSaveActions(); to make _absolutely sure_ the save actions are there. But... that shouldn't be necessary... normally it's done by default by the Create operation.
We're in a tricky spot right now.
As far as you're concerned:
And yet from our perspective:
So... I'm afraid the only thing we can do is:
@mikiman2028 , @zachweix - are you still encountering this issue? Maybe you can copy-paste some controller code here, to provide more insight?
@pxpm any other ideas?! I'm at a loss here...
This works for me. Definitely keep me posted if you find a fix!
Thank you for your help. I really appreciate it.
I am also at loss here. Unless something is preventing/removed when overriding some function (mean, create() and/or store()) I can't figure how this could happen.
From InlineCreate:
protected function setupInlineCreateDefaults()
{
if (method_exists($this, 'setup')) {
$this->setup();
}
if (method_exists($this, 'setupCreateOperation')) {
$this->setupCreateOperation();
}
$this->crud->applyConfigurationFromSettings('create');
}
Could this be the order of the Operations ? I see Inline before the Create.
Not sure, but might worth try to clear our mind out of it.
F --- * ---- * ---K !!! It's the order @tabacitu
@KevinRignault @selected-pixel-jameson @zachweix @mikiman2028
Please make sure that you load InlineCreateOperation AFTER the CreateOperation.
Do you see something we can do to fix this @tabacitu or just add to the docs ?
OMGβ¦. This fixed the issue as well. WOW.
Jameson Parker
Owner & Software Engineer
www.selectedpixel.com
www.linkedin.com/in/jamesonwparker
(920) 203-4106
On Sep 16, 2020, at 12:43 PM, Pedro Martins notifications@github.com wrote:
@KevinRignault https://github.com/KevinRignault @selected-pixel-jameson https://github.com/selected-pixel-jameson @zachweix https://github.com/zachweix @mikiman2028 https://github.com/mikiman2028
Please make sure that you load InlineCreateOperation AFTER the CreateOperation.Do you see something we can do to fix this @tabacitu https://github.com/tabacitu ?
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/Laravel-Backpack/CRUD/issues/2708#issuecomment-693558554, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGXF36K4BKCXVBFNLB7JM43SGD2NBANCNFSM4MQ357RQ.
I tested all you gave us, except the controller/model headers, I just used some I had here and changed the names to match yours, but the operations were already defined and I let them. (In correct order).
Sorry for letting this slip.
Best,
Pedro
Hahaha! Well... with the amount of effort everybody's put into this... it was bound to be something small π I was expecting one character but apparently it can be even smaller π
It makes sense now that you mention it @pxpm . InlineCreate can't re-use Create's setup, if it's not already there. Very good catch!
I think the best fix is to add this to the docs π
Yes! In LARGE BOLD LETTERS.
Jameson W Parker
On Sep 16, 2020, at 1:01 PM, Cristian Tabacitu notifications@github.com wrote:
ο»Ώ
Hahaha! Well... with the amount of effort everybody's put into this... it was bound to be something small π I was expecting one character but apparently it can be even smaller πIt makes sense now that you mention it @pxpm . InlineCreate can't re-use Create's setup, if it's not already there. Very good catch!
I think the best fix is to add this to the docs π
β
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Done: https://github.com/Laravel-Backpack/docs/commit/e2ae6718de4041682322f4ad71a28fcc147d267e
Thanks again for sticking with us @selected-pixel-jameson - this was a tricky one indeed π
@pxpm - I think I owe you a beer for this one πΊ
It's taken months, but that's it. Once I moved InlineCreate below Create, it worked and everything saved properly
Maybe we can make a change that an error should be thrown if inline create is included before create?
Hello @all I have the same error but I don't use InlineCreateOperation
@tabacitu fix, resolve the problem when I add $this->crud->setupDefaultSaveActions(); in my edit function.
Also adding use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation; fix as well the problem, even if I don't use/need it.
EDIT:
Another fix is to add $this->crud->applyConfigurationFromSettings('update'); in my edit($id) function
class PersonCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { edit as traitEdit; update as traitUpdate; }
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation { show as traitShow; }
//....
public function edit($id)
{
$this->crud->setupDefaultSaveActions(); // Fix the problem
$content = $this->traitEdit($id);
return $content;
}
//...
}
I will investigate to know why in my case.
EDIT 2: here is my finding and new solution
The root problem in my case is that the operation information is missing in my route.
I have custom routes in custom.php and I had the Route::crud(...); after my new routes
So I changed my new routes from:
Route::get('person/{personid}/edit', 'PersonCrudController@edit');
to:
Route::get('person/{personid}/edit', [
'as' => 'person.update',
'uses' => 'PersonCrudController@edit',
'operation' => 'update',
]);
and now it works!
Note: it looks like if I just add Route::crud('person', 'PersonCrudController'); before my others custom routes it also works.
In both cases, I need to do more testing though
Maybe @zachweix, @KevinRignault you or others have the same kind of issue ??
Most helpful comment
Could this be the order of the Operations ? I see Inline before the Create.
Not sure, but might worth try to clear our mind out of it.
EDIT:
F --- * ---- * ---K !!! It's the order @tabacitu