Skip to content

Commit

Permalink
Fix #10
Browse files Browse the repository at this point in the history
  • Loading branch information
z-song committed May 30, 2019
1 parent 94684e8 commit 0a64a68
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
17 changes: 12 additions & 5 deletions resources/views/select.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<div class="{{$viewClass['form-group']}} {!! !$errors->has($errorKey) ? '' : 'has-error' !!}">
<div class="{{$viewClass['form-group']}} {!! !$errors->hasAny($errorKey) ? '' : 'has-error' !!}">

<label for="{{$id}}" class="{{$viewClass['label']}} control-label">{{$label}}</label>

<div class="{{$viewClass['field']}} form-inline">

@include('admin::form.error')
@foreach($errorKey as $key => $col)
@if($errors->has($col))
@foreach($errors->get($col) as $message)
<label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$message}}</label><br/>
@endforeach
@endif
@endforeach

<div id="{{ $id }}" {!! $attributes !!}>
<select class="form-control" name="{{$name['province']}}"></select>
<select class="form-control" name="{{$name['city']}}"></select>
<select class="form-control" name="{{$name['district']}}"></select>
<select class="form-control" name="{{$name['province']}}"></select>&nbsp;
<select class="form-control" name="{{$name['city']}}"></select>&nbsp;
<select class="form-control" name="{{$name['district']}}"></select>&nbsp;
</div>
@include('admin::form.help-block')

Expand Down
24 changes: 24 additions & 0 deletions src/Distpicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a64a68

Please sign in to comment.