# Dynamic html attributes

**URL:** <https://community.weweb.io/t/dynamic-html-attributes/2156>\
**Category:** How do I?\
**Tags:** binding\
**Created:** [March 31, 2023, 4:47pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156 "2023-03-31T16:47:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![justifi](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/justifi/32/2846_2.png) [@justifi](https://community.weweb.io/u/justifi)\
**Post date:** [March 31, 2023, 4:47pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156/1 "2023-03-31T16:47:07Z")

</div>

I would like to dynamically apply HTML attributes to my form’s input elements.  
I am able to manually apply a set number of attributes using the **+Add** attribute button on the input element’s settings.

When I try to bind the attributes to a variable, nothing happens. I’ve tried several formats, but there’s no _expected format_ validation on this so I’m just guessing.

I’ve tried the formats below with 0 success

```auto
{ 
  "maxlength":"12",
  "minlength":"8"
}

```

and

```auto
[ 
  { "name":"maxlength", "value":"12"},
  { "name":"minlength", "value":"8"}
]

```

and

```auto
[ 
  { "maxlength": "12"},
  { "minlength": "8"}
]

```

help!

---

<div class="post-metadata">

**Author:** ![justifi](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/justifi/32/2846_2.png) [@justifi](https://community.weweb.io/u/justifi)\
**Post date:** [March 31, 2023, 4:57pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156/2 "2023-03-31T16:57:49Z")

</div>

Nevermind! Option 2 does the trick.

Is it possible to add boolean attributes in this array as well? e.g. **required**?

It appears that if the WeWeb component has a setting for the attribute (min, max, required etc), that attribute is ignored.

Is it possible to override those settings? What is the order of operations that they are applied?

I have built a CMS for my team where they can dynamically build a list of HTML attributes for our form inputs. It’s substantially less work for me to bind this entire list - rather than manually clicking through the available settings in WeWeb, doing a lookup in my attribute list, etc.

omitting **value** from the object does not work, e.g.

```auto
[ 
  { "name":"maxlength", "value":"12"},
  { "name":"minlength", "value":"9"},
  {"name":"required"}]

```

neither does providing a null e.g.

```auto
[ 
  { "name":"maxlength", "value":"12"},
  { "name":"minlength", "value":"9"},
  {"name":"required", "value":null}
]

```

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [March 31, 2023, 5:12pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156/3 "2023-03-31T17:12:30Z")

</div>

for boolean attributes try `"value":""` or `"value":"true"`

---

<div class="post-metadata">

**Author:** ![justifi](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/justifi/32/2846_2.png) [@justifi](https://community.weweb.io/u/justifi)\
**Post date:** [April 3, 2023, 2:03pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156/4 "2023-04-03T14:03:19Z")

</div>

Bumping in lieu of tagging moderators…

---

<div class="post-metadata">

**Author:** ![justifi](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/justifi/32/2846_2.png) [@justifi](https://community.weweb.io/u/justifi)\
**Post date:** [April 20, 2023, 2:56pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156/5 "2023-04-20T14:56:58Z")

</div>

The solution:

1. fork your desired component from [weweb-assets · GitHub](https://github.com/weweb-assets)
2. remove the relevant attributes in `src/wwElement.vue`
3. remove the corresponding settings in `ww-config.js`

From here, follow [the instructions to load your component inside weweb’s dev mode](https://developer.weweb.io/development-process.html#load-your-component-inside-weweb-io-in-dev-mode)

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [April 20, 2023, 6:41pm UTC](https://community.weweb.io/t/dynamic-html-attributes/2156/6 "2023-04-20T18:41:59Z")

</div>

1. keep your fork in sync with future updates
