Search code examples
meteormeteor-autoform

Meteor autoform remove asterisk form radio option


I have an autoform with select-radio-inline' type. the required asterisk shows in all the options. I want to remove it from the radio box. How to achieve?

enter image description here

Schema:

name: {
  type: String,
  autoform: {
    type: 'select-radio-inline',
    label: "Sex",
    afFieldInput: {
      options: function() {
        return [{
          label: "male",
          value: "male"
        }, {
          label: "female",
          value: "female"
        }];
      }
    }
  }
}

Solution

  • You can hide the asterisk by overwriting the corresponding CSS rule, for example:

    [data-required] label:after {
        content: '';
    }
    

    If you want to hide all asterisks for your name group only, you could create a div which wraps your AutoForm element and then use the div's identifier as a parent selector:

    #name > [data-required] label:after {
        content: '';
    }
    

    If you want to keep the asterisk for your label and just remove the asterisks for your radio options within the name group, you could use:

    [data-schema-key="name"] label:after {
        content: '';
    }
    

    Read more about the data-required attribute in Meteor AutoForm.