angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

Custom HTML Attributes in input field

Open sisodiakaran opened this issue 9 years ago • 5 comments

Is there a way to add custom attributes to input field?

I tried like this:

{
    "key" : "number",
    "placeholder" : "xxxx-xxxx-xxxx-xxxx",
    "data-braintree-name": "number"
}

Thanks

sisodiakaran avatar Jul 28 '16 12:07 sisodiakaran

Hi @sisodiakaran I don't think this is currently supported but this is something I've also wanted in the past. The ability to add data attributes to input fields. So like you say above, properties prefixed with 'data-' or maybe a 'data' object property like below (i've made up another data attribute called braintree-order)

{
    "key" : "number",
    "placeholder" : "xxxx-xxxx-xxxx-xxxx",
    "data": {
        "braintree-name": "number",
        "braintree-order": "3",
    }
}

Which would then appear in the rendered form html as:

<input
  type="text"
  name="number"
  placeholder="xxxx-xxxx-xxxx-xxxx"
  data-braintree-name="number"
  data-braintree-order="3">
...
/>

I don't think this is currently supported but it could be useful.

joelwkent avatar Jul 28 '16 13:07 joelwkent

Someone managed to insert html properties in inputs?

GustavoGottardi avatar Aug 19 '16 18:08 GustavoGottardi

Has anyone managed to insert html properties in inputs as of April 2017? I'm having this issue right now.

soccermatrix avatar Apr 03 '17 13:04 soccermatrix

@joelwkent did you ever get anywhere on this? I assume it would only take a template modification and a function on scope to serialize into a string like (using your example)

<input data-braintree-name="number" data-braintree-order="3"/>

An add on can modify the form object, so conceivably you could put the function in the form object and then modify the templates to call it once without too much trouble. Thoughts?

Anthropic avatar Apr 03 '17 13:04 Anthropic

Can anyone has resolved this issue?

JayDoshi8533 avatar May 28 '19 07:05 JayDoshi8533