nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

The dependent field disappears when dependent on an external field.

Open fenestron opened this issue 2 years ago • 3 comments

Code example:

Text::make('Recipient')
    ->readonly()
    ->dependsOn(
        ['type'],
        function (Text $field, NovaRequest $request, FormData $formData) {
            if ($formData->type === 'gift') {
                $field->readonly(false)->rules(['required', 'email']);
            }
        }
    ),

Flexible::make('Content')
    ->addLayout('Simple content section', 'wysiwyg', [
        Text::make('Recipient')
            ->readonly()
            ->dependsOn(
                ['type'],
                function (Text $field, NovaRequest $request, FormData $formData) {
                    if ($formData->type === 'gift') {
                        $field->readonly(false)->rules(['required', 'email']);
                    }
                }
            ),
    ]),

Select::make('Purchase Type', 'type')
    ->options([
        'personal' => 'Personal',
        'gift' => 'Gift',
    ])
    ->default('personal'),

Field behavior:

Laravel - Create Test

P.S. Example taken from documentation

fenestron avatar Apr 13 '22 15:04 fenestron