-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added option: "typeUserAttrs". #247
Conversation
}; | ||
|
||
//+ gimigliano | ||
if(opts.typeUserAttrs[values.type]) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this meant to wrap until L768?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I inserted only three blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but i meant that the conditional starts and ends on L735 because it has {}
. Once thats fixed we can merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No are 3 differents blocks don't see this page but find them in de .js file. It's more easy
I've been testing the last couple hours and seems to work well. In the future we may want to add support for boolean type attributes such as After fixing the conditional on L735 I can merge and will add documentation shortly after. Is it okay to use the PR description for documentation and demo? |
In today version yo can adda all the attributes you want they will be used without control (so disabled readonly onchange etc. too).
|
Looking good, but do
|
Yes, if
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking and working good. needs that one final change and should be good to go.
for (var val in options) if(val!='options' && val!='type' && val!='value' && options[val]!=undefined) selectOpen+=val+'="'+options[val].replace('"','"')+'"'; | ||
return '<div class="form-group ' + name + '-wrap">' | ||
+'<label for="' + name + '-' + lastID + '">'+opts.messages[name] +'</label>' | ||
+selectOpen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get the select properly i had to change this:
+'<' + selectOpen + '>'
I just saw your correction here but markup is still partially malformed and causes first option to not show.
Yes now is correct but I saw the select built correctly on firefox ... I hope now is closed |
Working good for me now. Good work on this, extremely useful feature. |
Documentation and demo of this feature in action has been added. http://formbuilder.readthedocs.io/en/latest/formBuilder/options/typeUserAttrs/ |
Nice feature. I thought it might come in handy for my validation problem but it doesn't. I'm using parsley.js and I want to validate a telephone number (US style) on the rendered form. There is no telephone sub type for a text field. Although, with parsley, I can add a data attribute to the generic text field (data-parsley-phone="true") and it will validate the field for the proper phone format. Unfortunately, there is no way to tack on user supplied attributes using this new option. It would be nice to have a field (e.g. attributes?) similar to the class field that would accept a string verbatim and tack that string onto the input tag. Saving and loading a form would also need to preserve those attributes. |
I was going to say you could use a pattern attribute similar to here but I saw it gets escaped so looks like some work is needed there. Edit: i just pushed a fix so attributes should be escaped correctly. Check this pen to see it in action but you may need to wait a bit since gh-pages seems to be a little slow today. I will also add a |
Thanks Kevin. The pattern doesn't solve my problem but adding tel as a sub type would (just tested it). If you are going to add tel, consider adding number also. These are really just text types but they allow mobile browsers to bring up the alternative keyboard. Cheers. |
@eradin The phone pattern is working for me locally but for some reason gh-pages is still serving v1.18.0 instead of v1.19.2. I understand it may not suit your use case though. Can you describe the number input? Is it just I'll add |
http://formbuilder.online/assets/js/form-builder.min.js is serving up 1.18. |
I just checked https://formbuilder.online/assets/js/form-builder.min.js and it seems to be serving 1.19.3 now. May need to clear cache. 1.19.3 has tel subtype of text |
Yup, that was the problem. Looks real good. Not to be picky but is there a simple way for you to make the dropdown say phone or telephone but insert a tel type? I'm afraid users won't get the short form name. |
That makes sense but would require a bit of refactoring to make happen. I'll look into it though when I get the chance. |
This feature have errors on the textUserAttrs function when you try to add a checkbox as a custom attribute field. The 'form-control' class added to the checkbox destroys its look and when you try to add a field on the defaultFields with this custom attribute set to true/false it is not setting the value. Anyway, I made a fix myself:
|
@dinevillar good catch on that. |
Suppose you want to add "min" and "max" to all "date" fields and moreover you want to add a parameter "columns" from 1 to 6 to all the "radio-group"