dcasia / conditional-container

Provides an easy way to conditionally show and hide fields in your Nova resources.
MIT License
115 stars 37 forks source link

Froala wysiwyg Uploading Image Issue #44

Open Slgoetz opened 3 years ago

Slgoetz commented 3 years ago

It seems that the Conditional Container removes the fields from the Nova Fields Collections so that ->availableFields() doesn't return them. When we try to upload an image we get a 404 since the field is non existent in the data. Is there another way to field the field, and is there a reason you're removing them from the Nova Field Collection?

milewski commented 3 years ago

All fields within a conditional container get removed if the if() condition doesn't match, that how this package works, in order to make this work with froala perhaps we need to modify the availableFields() method from the HasConditionalContainer to identify this is a request targeting some specific field within a possibly deep nested conditional container field

manyasone commented 3 years ago

A workaround for this is checking the requestUri, in my case using the QuillJs field:

/**
 * Get the fields displayed by the resource.
 *
 * @param \Illuminate\Http\Request $request
 * @return array
 */
public function fields(Request $request)
{
    ...

    if ($request->getRequestUri() === '/nova-vendor/quilljs/modules/upload/content') {
        $data[] = Quilljs::make(__('validation.attributes.content'), 'content')
            ->withFiles()
    }

    return $data;
}

I use this with the BelongsToManyField as well:

if ($request->getRequestUri() === '/nova-vendor/belongs-to-many-field/modules/options/videos/name') {
    $data[] = BelongsToManyField::make(__('validation.attributes.videos'), 'videos', $this->videoResource());
}