Skip to content

Commit d67f6e1

Browse files
Merge pull request yassilah#121 from alberto-bottarini/master
Add validation for nested form
2 parents 3fb8f76 + 9d2ed91 commit d67f6e1

File tree

4 files changed

+23
-67
lines changed

4 files changed

+23
-67
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/NestedFormField.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
: 'nova-nested-form-without-content'
88
"
99
>
10+
<help-text
11+
class="error-text mt-2 text-danger p-4"
12+
v-if="hasError"
13+
>
14+
{{ firstError }}
15+
</help-text>
16+
1017
<template v-if="shouldDisplay()">
1118
<template v-if="field.children && field.children.length > 0">
1219
<card
@@ -15,7 +22,11 @@
1522
v-for="(child, childIndex) in field.children"
1623
v-bind:style="getStyle(childIndex)"
1724
>
18-
<nested-form-header :child="child" :field="field" />
25+
<nested-form-header
26+
:child="child"
27+
:field="field"
28+
/>
29+
1930
<component
2031
:conditions="conditions"
2132
:errors="errors"

src/NestedForm.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ public function min(int $min)
298298
return $this->returnContext;
299299
}
300300

301+
/**
302+
* Set custom validation rules.
303+
*/
304+
public function rules($rules)
305+
{
306+
parent::rules($rules);
307+
308+
return $this->returnContext;
309+
}
310+
301311
/**
302312
* Set the condition to display the form.
303313
*/

yarn-error.log

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)