diff --git a/src/BackpackServiceProvider.php b/src/BackpackServiceProvider.php index 113f1c0090..4bed0a47f7 100644 --- a/src/BackpackServiceProvider.php +++ b/src/BackpackServiceProvider.php @@ -242,7 +242,7 @@ protected function mergeConfigFromOperationsDirectory() $operationConfigs = scandir(__DIR__.'/config/backpack/operations/'); $operationConfigs = array_diff($operationConfigs, ['.', '..']); - if (!count($operationConfigs)) { + if (! count($operationConfigs)) { return; } diff --git a/src/app/Library/CrudPanel/Traits/Fields.php b/src/app/Library/CrudPanel/Traits/Fields.php index 3e515f54eb..56ef42c7bf 100644 --- a/src/app/Library/CrudPanel/Traits/Fields.php +++ b/src/app/Library/CrudPanel/Traits/Fields.php @@ -429,13 +429,10 @@ public function getAllFieldNames() */ public function getStrippedSaveRequest() { - $setting = $this->getOperationSetting('saveAllInputsExcept'); - if ($setting == false || $setting == null) { - return $this->getRequest()->only($this->getAllFieldNames()); - } + $setting = $this->getOperationSetting('strippedRequest'); - if (is_array($setting)) { - return $this->getRequest()->except($this->getOperationSetting('saveAllInputsExcept')); + if (is_callable($setting)) { + return $setting($this->getRequest()); } return $this->getRequest()->only($this->getAllFieldNames()); diff --git a/src/config/backpack/crud.php b/src/config/backpack/crud.php index e799e7f3a0..8067cc8b35 100644 --- a/src/config/backpack/crud.php +++ b/src/config/backpack/crud.php @@ -1,7 +1,7 @@ false, - // Before saving the entry, how would you like the request to be stripped? - // - false - ONLY save inputs that have fields (safest) - // - [x, y, z] - save ALL inputs, EXCEPT the ones given in this array - 'saveAllInputsExcept' => false, - // 'saveAllInputsExcept' => ['_token', '_method', '_http_referrer', '_current_tab', '_save_action'], +/** + * Before saving the entry, how would you like the request to be stripped? + * - false - fall back to Backpack's default (ONLY save inputs that have fields) + * - closure - process your own request (example removes all inputs that begin with underscode). + * + * @param \Illuminate\Http\Request $request + * @return array + */ + // 'strippedRequest' => (function ($request) { + // return $request->except('_token', '_method', '_http_referrer', '_current_tab', '_save_action'); + // }), ]; diff --git a/src/config/backpack/operations/list.php b/src/config/backpack/operations/list.php index 0bc8e8678c..e860fac259 100644 --- a/src/config/backpack/operations/list.php +++ b/src/config/backpack/operations/list.php @@ -1,7 +1,7 @@ false, - // Before saving the entry, how would you like the request to be stripped? - // - false - Save ONLY inputs that have a field (safest, default); - // - [x, y, z] - Save ALL inputs, EXCEPT the ones given in this array; - 'saveAllInputsExcept' => false, - // 'saveAllInputsExcept' => ['_token', '_method', '_http_referrer', '_current_tab', '_save_action'], +/** + * Before saving the entry, how would you like the request to be stripped? + * - false - fall back to Backpack's default (ONLY save inputs that have fields) + * - closure - process your own request (example removes all inputs that begin with underscode). + * + * @param \Illuminate\Http\Request $request + * @return array + */ + // 'strippedRequest' => (function ($request) { + // return $request->except('_token', '_method', '_http_referrer', '_current_tab', '_save_action'); + // }), ];