Skip to content
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

Disabling either the 'name' or 'className' in form-editor options causes the rendered form to lose styling. #819

Closed
GrimzEcho opened this issue Sep 26, 2018 · 0 comments · Fixed by #842

Comments

@GrimzEcho
Copy link
Contributor

GrimzEcho commented Sep 26, 2018

Description:

To simplify the options that users have when creating a form, I want to use the disabledAttrs property of the form-editor options to remove these attributes from the rendered edit controls. However, instead of merely hiding the rendered element that set these values, the attribute itself is removed from the form. In the case of className, the rendered form does not have a default class attached it. For name the rendered form control does not have a name/group assigned (e.g. radio buttons will not be linked together).

This issue is similar to #544, but is more expansive and has a smaple project for demonstration.

Environment Details:

  • formBuilder Version: 2.98
  • Browser: Chrome, Firefox, Edge
  • OS: Windows 10, Ubuntu 18.04

Expected Behavior

When disabling a configuration attribute, I expect that the user won't be able to see or change that setting, but that the default value for the attribute will remain attached to the element (e.g. the edit control will be hidden, or otherwise non-interactable)

Actual Behavior

The attribute is completely removed from the element, breaking how the element is styled and rendered.

Steps to Reproduce

  1. Open the sample project at https://codepen.io/anon/pen/bmbdBx. This was forked from the toggle demo in the official documentation.
  2. Notice that the only change was the inclusion of disabledAttrs: ['name', 'className'], in the fbOptions object.
  3. Run the project and add some controls to the form.
  4. Click the save button to toggle the form viewer.
  5. Notice that the form is no longer styled correctly (or at all).

Workaround #1

Create static style rules for the various xxx-wrap, hiding the elements. Example:

$selectors: '.className-wrap, .name-wrap, .access-wrap, .multiple-wrap, .toggle-wrap, .subtype-wrap, .step-wrap, ' +
				'.rows-wrap';

#{$selectors} {
	display: none !important;
}

Workaround #2

If you need to dynamically set which attributes are hidden, then you need to style the incoming xxx-class elements as controls are added to the form and apply the styling to existing elements (such as if you load a saved form). Either use the onadd() and onclone() hooks, or use a simple element insertion library such as insertion-query, e.g.

$(() => {
	// hide any new attributes we don't want to see
	// uses CSS3 animation to efficiently detect when new elements are added to the DOM
	const selector = '.className-wrap, .name-wrap';
	insertionQ(selector).every(elm => {
		$(elm).hide();
	});
		
	// hide the existing attributes that have already been loaded/rendered
	$(selector).hide();			
});
@GrimzEcho GrimzEcho changed the title Disabling either the 'name' or 'className' in form-editor options causes the rendered form to loose styling. Disabling either the 'name' or 'className' in form-editor options causes the rendered form to lose styling. Sep 26, 2018
kevinchappell added a commit that referenced this issue Oct 31, 2018
* Code format changes

* wip

* Update Demo, expose api normal jQuery plugin way

* remove indexRender.html, unify demos

* remove demoRender.css

* Fix duplicate custom controls, toggle render

* remove regen dep

* update demo

* remove gulp

* upgrade module, webpack and minor style changes

* autocomplete.js code style

* update docs

* Update docs

* Add travis.yml

Remove unused modules

Update icon-font editing and saving

* Remove test data, improve stickyControls, ensure DOM is ready

* reduce file churn

* Remove columns doc

* update mi18n, add support checkbox custom attributes, bump version

* Fix label overflow problem, resolves #779

* Add allowStageSort option, resolves #777

* Add documentation

* Enable multiple select field for typeUserAttrs, resolves #776

* fix bug where empty className is not applied

* Features: onFieldAdd option and toggleFieldEdit action, resolves #772

* Add setData and render actions to formRender, resolves #770

* fix attribute placeholder typo, fix label added when it should be removed, resolves #763

* label saving issue for html labels WIP

* Fix label saving, add esc to close data modal, resolves #757

* update font editing docs

* feature, add toggletAllFieldEdit

* Add onOpenFieldEdit option, closeAllFieldEdit action, scrollToFieldOnAdd option

* fix inputset bug

* start fieldEditContainer option

* remove console.log, use spaces instead of tabs for data formatting

* Add layout and layout templates docs

* fix(label): ensure html from label is correctly escaped, resolves #816

* Code style changes

* Fix code style

* Add: replaceFields, cleanup

* Update docs, do not disable className or name attributes- resolves #819

* Update typeUserAttrs docs, resolves #810

* Other option should hide input value when deselected, resolves #808

* Ensure custom attributes are included in exported data
resolves #824
resolves #773

* Add: disableHTMLLabels option, resolves #747

* remove replace comma, resolves #740

* Fix attrString util, Add: disableSubtypes, resolves #739

* Fix: current formData not carried over to new formBuilder instance on language change, resolves #735

* Fix: name attribute for inputs with multiple, resolves #736

* add onremove to typeUserEvents

* Fix: new option name, resolves #687

* Fix: doubleclick event handler, resolves #535

* Lock dev dependency versions

* Fixed issue 530.  Modified helpers.js::xmlSave() to serialize field data so any XML in a field's attributes is properly escaped. (#804)

* Fix bug with clear() as reported in #750 (#828)

Add control type check to clear() so that method doesn't reset the value for checkboxes and radio buttons, which caused the userData getter to work incorrectly.

* use yarn instead of npm

* Update xmlSave

* Demo build updates WIP

* Use existing formBuilder instance instead of creating a new one on setLang

* add formbuilder-languages module, remove network dependency, cleanup

* fix typo

* Fix inline checkbox/radio

* Add deploy script

* Just ensure build passes for now so we can get this release out this week

* v2.10.0
kevinchappell added a commit that referenced this issue Oct 31, 2018
* Code format changes

* wip

* Update Demo, expose api normal jQuery plugin way

* remove indexRender.html, unify demos

* remove demoRender.css

* Fix duplicate custom controls, toggle render

* remove regen dep

* update demo

* remove gulp

* upgrade module, webpack and minor style changes

* autocomplete.js code style

* update docs

* Update docs

* Add travis.yml

Remove unused modules

Update icon-font editing and saving

* Remove test data, improve stickyControls, ensure DOM is ready

* reduce file churn

* Remove columns doc

* update mi18n, add support checkbox custom attributes, bump version

* Fix label overflow problem, resolves #779

* Add allowStageSort option, resolves #777

* Add documentation

* Enable multiple select field for typeUserAttrs, resolves #776

* fix bug where empty className is not applied

* Features: onFieldAdd option and toggleFieldEdit action, resolves #772

* Add setData and render actions to formRender, resolves #770

* fix attribute placeholder typo, fix label added when it should be removed, resolves #763

* label saving issue for html labels WIP

* Fix label saving, add esc to close data modal, resolves #757

* update font editing docs

* feature, add toggletAllFieldEdit

* Add onOpenFieldEdit option, closeAllFieldEdit action, scrollToFieldOnAdd option

* fix inputset bug

* start fieldEditContainer option

* remove console.log, use spaces instead of tabs for data formatting

* Add layout and layout templates docs

* fix(label): ensure html from label is correctly escaped, resolves #816

* Code style changes

* Fix code style

* Add: replaceFields, cleanup

* Update docs, do not disable className or name attributes- resolves #819

* Update typeUserAttrs docs, resolves #810

* Other option should hide input value when deselected, resolves #808

* Ensure custom attributes are included in exported data
resolves #824
resolves #773

* Add: disableHTMLLabels option, resolves #747

* remove replace comma, resolves #740

* Fix attrString util, Add: disableSubtypes, resolves #739

* Fix: current formData not carried over to new formBuilder instance on language change, resolves #735

* Fix: name attribute for inputs with multiple, resolves #736

* add onremove to typeUserEvents

* Fix: new option name, resolves #687

* Fix: doubleclick event handler, resolves #535

* Lock dev dependency versions

* Fixed issue 530.  Modified helpers.js::xmlSave() to serialize field data so any XML in a field's attributes is properly escaped. (#804)

* Fix bug with clear() as reported in #750 (#828)

Add control type check to clear() so that method doesn't reset the value for checkboxes and radio buttons, which caused the userData getter to work incorrectly.

* use yarn instead of npm

* Update xmlSave

* Demo build updates WIP

* Use existing formBuilder instance instead of creating a new one on setLang

* add formbuilder-languages module, remove network dependency, cleanup

* fix typo

* Fix inline checkbox/radio

* Add deploy script

* Just ensure build passes for now so we can get this release out this week

* v2.10.0
pfranza pushed a commit to pfranza/formBuilder that referenced this issue Nov 21, 2018
* Code format changes

* wip

* Update Demo, expose api normal jQuery plugin way

* remove indexRender.html, unify demos

* remove demoRender.css

* Fix duplicate custom controls, toggle render

* remove regen dep

* update demo

* remove gulp

* upgrade module, webpack and minor style changes

* autocomplete.js code style

* update docs

* Update docs

* Add travis.yml

Remove unused modules

Update icon-font editing and saving

* Remove test data, improve stickyControls, ensure DOM is ready

* reduce file churn

* Remove columns doc

* update mi18n, add support checkbox custom attributes, bump version

* Fix label overflow problem, resolves kevinchappell#779

* Add allowStageSort option, resolves kevinchappell#777

* Add documentation

* Enable multiple select field for typeUserAttrs, resolves kevinchappell#776

* fix bug where empty className is not applied

* Features: onFieldAdd option and toggleFieldEdit action, resolves kevinchappell#772

* Add setData and render actions to formRender, resolves kevinchappell#770

* fix attribute placeholder typo, fix label added when it should be removed, resolves kevinchappell#763

* label saving issue for html labels WIP

* Fix label saving, add esc to close data modal, resolves kevinchappell#757

* update font editing docs

* feature, add toggletAllFieldEdit

* Add onOpenFieldEdit option, closeAllFieldEdit action, scrollToFieldOnAdd option

* fix inputset bug

* start fieldEditContainer option

* remove console.log, use spaces instead of tabs for data formatting

* Add layout and layout templates docs

* fix(label): ensure html from label is correctly escaped, resolves kevinchappell#816

* Code style changes

* Fix code style

* Add: replaceFields, cleanup

* Update docs, do not disable className or name attributes- resolves kevinchappell#819

* Update typeUserAttrs docs, resolves kevinchappell#810

* Other option should hide input value when deselected, resolves kevinchappell#808

* Ensure custom attributes are included in exported data
resolves kevinchappell#824
resolves kevinchappell#773

* Add: disableHTMLLabels option, resolves kevinchappell#747

* remove replace comma, resolves kevinchappell#740

* Fix attrString util, Add: disableSubtypes, resolves kevinchappell#739

* Fix: current formData not carried over to new formBuilder instance on language change, resolves kevinchappell#735

* Fix: name attribute for inputs with multiple, resolves kevinchappell#736

* add onremove to typeUserEvents

* Fix: new option name, resolves kevinchappell#687

* Fix: doubleclick event handler, resolves kevinchappell#535

* Lock dev dependency versions

* Fixed issue 530.  Modified helpers.js::xmlSave() to serialize field data so any XML in a field's attributes is properly escaped. (kevinchappell#804)

* Fix bug with clear() as reported in kevinchappell#750 (kevinchappell#828)

Add control type check to clear() so that method doesn't reset the value for checkboxes and radio buttons, which caused the userData getter to work incorrectly.

* use yarn instead of npm

* Update xmlSave

* Demo build updates WIP

* Use existing formBuilder instance instead of creating a new one on setLang

* add formbuilder-languages module, remove network dependency, cleanup

* fix typo

* Fix inline checkbox/radio

* Add deploy script

* Just ensure build passes for now so we can get this release out this week

* v2.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant