brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
607 stars 168 forks source link

Password field #97

Closed ma-hack closed 7 years ago

ma-hack commented 7 years ago

I have in the form a field that contains a password. Please, can you integrate support for the html input type option "password"? I look in the documentation but can not found anything about it.

Best regards, Marco

fabifabi commented 7 years ago

use decorator ? not so hard ;)

ma-hack commented 7 years ago

The generated ui is dynamic and can have multiple password fields. When i use a decorator then i must know before i get the schema which fields are the password fields.

Have you an example how this can be work? I already look over the example: https://github.com/brutusin/json-forms/blob/master/src/js/brutusin-json-forms-bootstrap.js

fabifabi commented 7 years ago

can u show me your source ? or send to me ?

ma-hack commented 7 years ago

Sorry, that is not possible because it is a larger JavaEE project with multiple applications. The applications offer an webservice what provides the data as JSON Schema (jackson-mapper). This schema is used in the webfrontend to build a configuration ui to change the settings of this application.

I use in the schema fields like readOnly, title, description, etc. My hope was that it is possible to set something like form:password in the schema and brutusin display the field as password field.

idelvall commented 7 years ago

@fabifabi maybe you can show him some examples of decorators, like the ones used for selecting colors or folders?

fabifabi commented 7 years ago

i never did dynamic schema.....thats' change something of the problem ? if not,i will post it tomorow,i use some plugin for color slecting (spectrum,if u know,very good one !) i need do a more easy sample.

Btw! conrgat,u are in a french magazine this month ;)

fabifabi commented 7 years ago

BrutusinForms.addDecorator(function (e, s) { var $this = $(e); if (s && s.format === "color") $this.attr("type", "color"); });

with Jquery.

idelvall commented 7 years ago

Maybe this example is good for the question too: http://brutusin.org/json-forms/#9 The insight is to add a custom format to the strings, for example "password" and add a decorator that whenever this format is used in a string input, it change the type of the input accordingly

idelvall commented 7 years ago

Thanks @fabifabi! You rock man

fabifabi commented 7 years ago

full agree

2017-07-21 16:43 GMT+02:00 Ignacio del Valle Alles <notifications@github.com

:

Maybe this example is good for the question too: http://brutusin.org/json- forms/#9 The insight is to add a custom format to the strings, for example "password" and add a decorator that whenever this format is used in a string input, it change the type of the input accordingly

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/brutusin/json-forms/issues/97#issuecomment-317019876, or mute the thread https://github.com/notifications/unsubscribe-auth/AYbVLVYV_UMUPaOFztZJxsHxVg6Pox_tks5sQLj_gaJpZM4OfOQC .

ma-hack commented 7 years ago

Thank you very much for your help! That easy solution works!!

For others just put in the schema a format tag {"title":"Password", "description":"If authentification is needed than specifiy the password.", "format":"password", "type":"string"}

upper the brutusin js add the decorator BrutusinForms.addDecorator(function (element, s) { var $this = $(element); if (s && s.format === "password") { $this.attr("type", "password"); } });