json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Custom HTML Attributes in input field #744

Open sisodiakaran opened 8 years ago

sisodiakaran commented 8 years ago

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

joelwkent commented 8 years ago

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.

GustavoGottardi commented 8 years ago

Someone managed to insert html properties in inputs?

soccermatrix commented 7 years ago

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

Anthropic commented 7 years ago

@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?

JayDoshi8533 commented 5 years ago

Can anyone has resolved this issue?