Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeUserAttrs and data- attribute #1588

Open
looc opened this issue Sep 24, 2024 · 1 comment
Open

typeUserAttrs and data- attribute #1588

looc opened this issue Sep 24, 2024 · 1 comment
Labels

Comments

@looc
Copy link

looc commented Sep 24, 2024

  • formBuilder Version:
  • Browser: 3.19.12
  • OS: windows

Adding a custom attribute with the name of data-validatortitle will be stored as datavalidatortitle
How can we add data- attributes?

options = {
      typeUserAttrs: {
        '*':{
          'data-validatortitle': {
              label: 'Validatortitle',
              value: ''
          }
        }
      }
    };

Will give an attribute with the name of "datavalidatortitle" so the - is lost.

One option would be to add a title attribute:

options = {
      typeUserAttrs: {
        text:{
          title: {
              label: 'Validatortitle',
              value: ''
          }
        }
      }
    };

But title attribute is not renderd on checkbox and radio

@lucasnetau
Copy link
Collaborator

What version are you using? Either data-hypen-case or dataCamelCase will work fine for defining a custom attribute.

typeUserAttrs: {
            '*': {
                'dataMyData': {
                    label: 'Data camelCase',
                    value: '',
                },
                'data-my-data2': {
                    label: 'Data Hyphen',
                    value: '',
                },

It will be saved in camelCase

    "dataMyData": "abc",
    "dataMyData2": "123",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants