Skip to main content
Nintex Community Menu Bar
Question

How do I remove required field styling

  • July 9, 2024
  • 6 replies
  • 0 views
  • Translate

Forum|alt.badge.img+20

Did this topic help you find an answer to your question?
This topic has been closed for comments

6 replies

Forum|alt.badge.img+13

There are 2 approaches I can think of to remove the styling:

1. Create a generic Custom Field Renderer Snippet called something like “RemoveRequired” on these fields whose only purpose is to remove the .required class from the Field’s elements. Here’s what this Snippet would look like:

var field = arguments[0],
   value = skuid.utils.decodeHTML(arguments[1]);
skuid.ui.fieldRenderers[field.metadata.displaytype]field.mode;
setTimeout(function(){
   field.element.removeClass(‘required’);    
},1);

Then use this Custom Field Renderer for all of these fields.

I’d recommend this approach.

2. Override the required field styling using CSS. This is going to be difficult because you’ll have to make the CSS even more selective than Skuid’s default rules.

Translate

Forum|alt.badge.img+13

NOTE: I just modified the snippet, turns out that the required class is currently to the field element after the renderer is run, making it impossible to remove this class without using waiting until the next pass of the event loop with setTimeout(), but this approach will work consistently. 

Translate

Forum|alt.badge.img+20

How do I make it a picklist?

Translate

Forum|alt.badge.img+13


Ugh, that’s true, for Reference fields that you want to be picklists you’d have to have a separate snippet called “ReferenceFieldAsPicklist_RemoveRequired” or something like that, which would look like this:


var field = arguments[0],
   value = skuid.utils.decodeHTML(arguments[1]);
field.options.type = ‘REFPICK’;
skuid.ui.fieldRenderers[field.metadata.displaytype]field.mode;
field.options.type = ‘CUSTOM’;
setTimeout(function(){
   field.element.removeClass(‘required’);    
},1);

Translate

Forum|alt.badge.img+20

Why do we have to declare both REFPICK and CUSTOM?

Translate

Forum|alt.badge.img+13

You have to declare REFPICK so that the Reference field renders as a Picklist, then you have to reset it to CUSTOM so that your custom renderer will be run the next time, rather than the regular Reference-Picklist renderer. If you don’t reset it, your Required styling will “come back” the next time you go into Edit mode.

Translate

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings