statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

required_if not working on fieldset #2543

Closed stuartcusackie closed 2 years ago

stuartcusackie commented 2 years ago

Describe the bug I have a 'Button' field set with various fields for dynamic buttons that handle documents, entries and regular urls.

I'll just take an example of two particular fields: btn_typeand btn_url. These two fields are configured like so:

  -
    handle: btn_type
    field:
      options:
        document: Document
        entry: Entry
        url: Url
      multiple: false
      clearable: false
      searchable: true
      taggable: false
      push_tags: false
      cast_booleans: false
      default: url
      display: 'Button Type'
      type: select
      icon: select
      width: 50
      listable: hidden
      instructions_position: above
      validate:
        - required
  -
    handle: btn_url
    field:
      input_type: url
      antlers: false
      display: URL
      type: text
      icon: text
      width: 50
      listable: hidden
      instructions_position: above
      validate:
        - 'required_if:btn_type,url'
      if:
        btn_type: 'equals url'

The fieldset is then added to a Bard field.

The problem is that I don't get any validation errors when saving a blank URL field. I have tried various validation rules to no avail:

stuartcusackie commented 2 years ago

I posted in the wrong hub.