Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dependent field support #444

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions resources/js/components/fields/FormField.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<component :is="field.fullSize ? 'FullWidthField' : 'DefaultField'" :field="field" :errors="errors" :show-help-text="showHelpText">
<component :is="field.fullSize ? 'FullWidthField' : 'DefaultField'" :field="currentField" :errors="errors" :show-help-text="showHelpText">
<template #field>
<div :class="{'px-8 pt-6': field.fullSize}">
<gallery slot="value" ref="gallery" v-if="hasSetInitialValue"
Expand All @@ -24,15 +24,15 @@
</template>

<script>
import {FormField, HandlesValidationErrors} from 'laravel-nova';
import {DependentFormField, HandlesValidationErrors} from 'laravel-nova';
import Gallery from '../Gallery';
import FullWidthField from '../FullWidthField';
import ExistingMedia from '../ExistingMedia';
import objectToFormData from 'object-to-formdata';
import get from 'lodash/get';

export default {
mixins: [FormField, HandlesValidationErrors],
mixins: [DependentFormField, HandlesValidationErrors],
components: {
Gallery,
FullWidthField,
Expand Down
3 changes: 2 additions & 1 deletion src/Fields/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Laravel\Nova\Fields\Field;
use Laravel\Nova\Fields\SupportsDependentFields;
use Laravel\Nova\Http\Requests\NovaRequest;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
Expand All @@ -17,7 +18,7 @@

class Media extends Field
{
use HandlesCustomPropertiesTrait, HandlesConversionsTrait, HandlesExistingMediaTrait;
use HandlesCustomPropertiesTrait, HandlesConversionsTrait, HandlesExistingMediaTrait, SupportsDependentFields;

public $component = 'advanced-media-library-field';

Expand Down