diff --git a/resources/views/select.blade.php b/resources/views/select.blade.php index a77d5db..b4e7f31 100644 --- a/resources/views/select.blade.php +++ b/resources/views/select.blade.php @@ -1,14 +1,21 @@ -
+
- @include('admin::form.error') + @foreach($errorKey as $key => $col) + @if($errors->has($col)) + @foreach($errors->get($col) as $message) +
+ @endforeach + @endif + @endforeach +
- - - +   +   +  
@include('admin::form.help-block') diff --git a/src/Distpicker.php b/src/Distpicker.php index f6b0ecd..2967f00 100644 --- a/src/Distpicker.php +++ b/src/Distpicker.php @@ -47,6 +47,30 @@ public function __construct($column, $arguments) $this->label = empty($arguments) ? '地区选择' : current($arguments); } + public function getValidator(array $input) + { + if ($this->validator) { + return $this->validator->call($this, $input); + } + + $rules = $attributes = []; + + if (!$fieldRules = $this->getRules()) { + return false; + } + + foreach ($this->column as $key => $column) { + if (!Arr::has($input, $column)) { + continue; + } + $input[$column] = Arr::get($input, $column); + $rules[$column] = $fieldRules; + $attributes[$column] = $this->label."[$column]"; + } + + return \validator($input, $rules, $this->getValidationMessages(), $attributes); + } + /** * @param int $count * @return $this