diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4294799081..37225734e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,7 +20,7 @@ All Notable changes to `Backpack CRUD` will be documented in this file
- Nothing
-## [3.2.0] - 2017-xx-xx
+## [3.2.0] - 2017-02-xx
### Added
- form save button better UI&UX: they have the options in a dropdown instead of radio buttons and the default behaviour is stored in the session upon change - thanks to [Owen Melbourne](https://github.com/OwenMelbz);
@@ -28,6 +28,8 @@ All Notable changes to `Backpack CRUD` will be documented in this file
- filters on list views (deleted the 3.1.41 and 4.1.42 tags because they were breaking changes);
- routes are now abstracted intro CrudRoute, so that new routes can be easily added;
- Greek translation (thanks [Stamatis Katsaounis](https://github.com/skatsaounis));
+- tabbed create&update forms - thanks to [Owen Melbourne](https://github.com/OwenMelbz);
+- grouped and inline errors - thanks to [Owen Melbourne](https://github.com/OwenMelbz);
### Fixed
- excluded _method from massAssignment, so create/update errors will be more useful;
diff --git a/src/CrudPanel.php b/src/CrudPanel.php
index 2bb51e0027..c8768841df 100644
--- a/src/CrudPanel.php
+++ b/src/CrudPanel.php
@@ -8,6 +8,7 @@
use Backpack\CRUD\PanelTraits\Access;
use Backpack\CRUD\PanelTraits\Create;
use Backpack\CRUD\PanelTraits\Delete;
+use Backpack\CRUD\PanelTraits\Errors;
use Backpack\CRUD\PanelTraits\Fields;
use Backpack\CRUD\PanelTraits\Update;
use Backpack\CRUD\PanelTraits\AutoSet;
@@ -22,7 +23,7 @@
class CrudPanel
{
- use Create, Read, Update, Delete, Reorder, Access, Columns, Fields, Query, Buttons, AutoSet, FakeFields, FakeColumns, ViewsAndRestoresRevisions, AutoFocus, Filters, Tabs;
+ use Create, Read, Update, Delete, Errors, Reorder, Access, Columns, Fields, Query, Buttons, AutoSet, FakeFields, FakeColumns, ViewsAndRestoresRevisions, AutoFocus, Filters, Tabs;
// --------------
// CRUD variables
@@ -64,6 +65,11 @@ class CrudPanel
// The following methods are used in CrudController or your EntityCrudController to manipulate the variables above.
+ public function __construct()
+ {
+ $this->setErrorDefaults();
+ }
+
// ------------------------------------------------------
// BASICS - model, route, entity_name, entity_name_plural
// ------------------------------------------------------
diff --git a/src/PanelTraits/Errors.php b/src/PanelTraits/Errors.php
new file mode 100644
index 0000000000..e50ead1bc2
--- /dev/null
+++ b/src/PanelTraits/Errors.php
@@ -0,0 +1,57 @@
+groupedErrors = config('backpack.crud.show_grouped_errors', true);
+ $this->inlineErrors = config('backpack.crud.show_inline_errors', false);
+ }
+
+ // Getters
+
+ public function groupedErrorsEnabled()
+ {
+ return $this->groupedErrors;
+ }
+
+ public function inlineErrorsEnabled()
+ {
+ return $this->inlineErrors;
+ }
+
+ // Setters
+
+ public function enableGroupedErrors()
+ {
+ $this->groupedErrors = true;
+
+ return $this->groupedErrors;
+ }
+
+ public function disableGroupedErrors()
+ {
+ $this->groupedErrors = false;
+
+ return $this->groupedErrors;
+ }
+
+ public function enableInlineErrors()
+ {
+ $this->inlineErrors = true;
+
+ return $this->inlineErrors;
+ }
+
+ public function disableInlineErrors()
+ {
+ $this->inlineErrors = false;
+
+ return $this->inlineErrors;
+ }
+}
diff --git a/src/PanelTraits/Filters.php b/src/PanelTraits/Filters.php
index f0ce44de5a..53b1284418 100644
--- a/src/PanelTraits/Filters.php
+++ b/src/PanelTraits/Filters.php
@@ -6,13 +6,31 @@
trait Filters
{
- // ------------
- // FILTERS
- // ------------
-
public $filters = [];
- public function __construct()
+ public function filtersEnabled()
+ {
+ return ! is_array($this->filters);
+ }
+
+ public function filtersDisabled()
+ {
+ return is_array($this->filters);
+ }
+
+ public function enableFilters()
+ {
+ if ($this->filtersDisabled()) {
+ $this->filters = new FiltersCollection;
+ }
+ }
+
+ public function disableFilters()
+ {
+ $this->filters = [];
+ }
+
+ public function clearFilters()
{
$this->filters = new FiltersCollection;
}
@@ -32,6 +50,9 @@ public function addFilter($options, $values = false, $filter_logic = false)
$values = $values();
}
+ // enable the filters functionality
+ $this->enableFilters();
+
// check if another filter with the same name exists
if (! isset($options['name'])) {
abort(500, 'All your filters need names.');
diff --git a/src/config/backpack/crud.php b/src/config/backpack/crud.php
index 7057634ea3..d7e1a608f1 100644
--- a/src/config/backpack/crud.php
+++ b/src/config/backpack/crud.php
@@ -7,17 +7,21 @@
| Backpack\CRUD preferences
|--------------------------------------------------------------------------
*/
+
+ /*
+ |------------
+ | CREATE & UPDATE
+ |------------
+ */
// Where do you want to redirect the user by default, after a CRUD entry is saved in the Add or Edit forms?
'default_save_action' => 'save_and_back', //options: save_and_back, save_and_edit, save_and_new
// When using tabbed forms (create & update), what kind of tabs would you like?
'tabs_type' => 'horizontal', //options: horizontal, vertical
- /*
- |------------
- | CREATE
- |------------
- */
+ // How would you like the validation errors to be shown?
+ 'show_grouped_errors' => true,
+ 'show_inline_errors' => true,
/*
|------------
@@ -34,12 +38,6 @@
// PREVIEW
- /*
- |------------
- | UPDATE
- |------------
- */
-
/*
|------------
| DELETE
diff --git a/src/resources/views/create.blade.php b/src/resources/views/create.blade.php
index 0a23359d54..1d25ce39a3 100644
--- a/src/resources/views/create.blade.php
+++ b/src/resources/views/create.blade.php
@@ -21,17 +21,7 @@
{{ trans('backpack::crud.back_to_all') }} {{ $crud->entity_name_plural }}
@endif
- {{-- Show the errors, if any --}}
- @if ($errors->any())
-