diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 57b0b98..0000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/resources/views/array-fields/error-help.blade.php b/resources/views/array-fields/error-help.blade.php
index 07e4d39..65be51d 100644
--- a/resources/views/array-fields/error-help.blade.php
+++ b/resources/views/array-fields/error-help.blade.php
@@ -1,6 +1,6 @@
@error($field->key . '.' . $key . '.' . $array_field->name)
- {{ $this->errorMessage($message) }}
+ {{ $message }}
@elseif($array_field->help)
{{ $array_field->help }}
diff --git a/src/FormComponent.php b/src/FormComponent.php
index 29129fb..986ae7d 100644
--- a/src/FormComponent.php
+++ b/src/FormComponent.php
@@ -61,12 +61,13 @@ public function fields()
public function updated($field)
{
- $this->validateOnly($field, $this->rules(true));
+ $this->validateOnly($field, $this->rules(true), [], $this->attributes());
}
public function submit()
{
- $this->validate($this->rules());
+
+ $this->validate($this->rules(), [], $this->attributes());
$field_names = [];
foreach ($this->fields() as $field) $field_names[] = $field->name;
@@ -75,11 +76,6 @@ public function submit()
$this->success();
}
- public function errorMessage($message)
- {
- return str_replace('form data.', '', $message);
- }
-
public function success()
{
$this->form_data['password'] = bcrypt($this->form_data['password']);
@@ -108,4 +104,26 @@ public function saveAndGoBackResponse()
{
return redirect()->route('users.index');
}
+
+ public function attributes()
+ {
+ $attributes = [];
+
+ /** @var Field $field */
+ foreach ($this->fields() as $field) {
+
+ if ($field->type === 'array') {
+
+ /** @var Field $arrayField */
+ foreach ($field->array_fields as $arrayField) {
+ $attributes[$field->key . '.*.' . $arrayField->name] = $arrayField->placeholder ?? $arrayField->name;
+ }
+
+ } else {
+ $attributes[$field->key] = $field->label;
+ }
+ }
+
+ return $attributes;
+ }
}