apostrophe icon indicating copy to clipboard operation
apostrophe copied to clipboard

3.0: Oembed field type can not be optional

Open myovchev opened this issue 3 years ago • 1 comments

To Reproduce

Imaginary oembed gallery widget:

module.exports = {
  extend: '@apostrophecms/widget-type',
  options: {
    label: 'Video gallery',
    icon: 'video-icon'
  },
  fields: {
    add: {
      main: {
        type: 'oembed',
        name: 'main',
        label: 'Main video URL (optional)',
        oembedType: 'video'
      },
      // ...more fields
    }
  }
};

Once something is typed in the main field, it can not be deleted, as validation error 'video URL invalid' is preventing the save action of the widget. Additionally, if left empty (it's possible if nothing is typed), the main field will contain:

{
  "url": null,
  "title": "",
  "thumbnail": null
}

I'm not sure if it's intended, but just null sounds better in nunjucks environment because it is counter intuitive and would simplify an eventual template check - if main against if main.url

Expected behavior

oembed field type should be allowed to be optional.

Details

Apostrophe version: 3.0.1

myovchev avatar Jul 27 '21 21:07 myovchev

Thanks for the report. I'll get this logged.

abea avatar Jul 29 '21 15:07 abea