Skip to content

Commit

Permalink
Merge pull request #121 from alberto-bottarini/master
Browse files Browse the repository at this point in the history
Add validation for nested form
  • Loading branch information
alberto-bottarini authored Jan 15, 2021
2 parents 3fb8f76 + 9d2ed91 commit d67f6e1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 67 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion resources/js/components/NestedFormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
: 'nova-nested-form-without-content'
"
>
<help-text
class="error-text mt-2 text-danger p-4"
v-if="hasError"
>
{{ firstError }}
</help-text>

<template v-if="shouldDisplay()">
<template v-if="field.children && field.children.length > 0">
<card
Expand All @@ -15,7 +22,11 @@
v-for="(child, childIndex) in field.children"
v-bind:style="getStyle(childIndex)"
>
<nested-form-header :child="child" :field="field" />
<nested-form-header
:child="child"
:field="field"
/>

<component
:conditions="conditions"
:errors="errors"
Expand Down
10 changes: 10 additions & 0 deletions src/NestedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ public function min(int $min)
return $this->returnContext;
}

/**
* Set custom validation rules.
*/
public function rules($rules)
{
parent::rules($rules);

return $this->returnContext;
}

/**
* Set the condition to display the form.
*/
Expand Down
65 changes: 0 additions & 65 deletions yarn-error.log

This file was deleted.

0 comments on commit d67f6e1

Please sign in to comment.