Single Choice - The choices are there but the font disappeared

I removed the old code from the json export and readded another single choice field and still no go.

"component": {
"type": "SingleChoice",
"model": {
"_internalName": "Type",
"title": {
"text": "Type of Time",
"visible": true
},
"orientation": "Vertical",
"required": true,
"font": {
"style": "Normal",
"weight": "Semibold"
},
"wrap": true,
"cFont": {
"style": "Normal",
"weight": "Normal"
},
"cColumns": 1,
"options": "Vacation\nSick\nBirthday\nWork from Home\nDiscretionary\nOther",
"defaultValue": [

                                      ]
                                    }
                                  }

image

To better assist you, we will need a bit more information. Specifically:

  1. Description of the Issue: What exactly is not working with the new SingleChoice field? Are there any error messages, or is the field not displaying as expected?
  2. Desired Outcome: What behavior are you expecting from this SingleChoice field? Is there any specific functionality you are looking to implement?
  3. Code Context: Are there any additional scripts or configurations that might be affecting this field?

Sure. The radio buttons show up, but the font does not show up. There is no other code that should be affecting it.

You can try using custom CSS and JavaScript rather than modifying the JSON directly.

Custom CSS

Add the following CSS to ensure the font styles are applied correctly to the radio button labels:

/* Custom CSS for SingleChoice component */
.plumsail-form .plumsail-radio-buttons label {
    font-style: normal; /* Apply normal style */
    font-weight: 600;   /* Semibold corresponds to 600 */
}

JavaScript

Add the following JavaScript to dynamically apply the styles when the form is rendered:

fd.rendered(function() {
    // Apply styles to all labels within radio buttons
    document.querySelectorAll('.plumsail-radio-buttons label').forEach(function(element) {
        element.style.fontStyle = 'normal';
        element.style.fontWeight = '600'; // Semibold
    });
});

Thanks. I added both pieces of code, css and js, and nothing seems to have changed. I am at a loss. Here is the json.
New Time-Off-Request.json (26.1 KB)

I removed everything from the form except the single option field and I still can't see the font.

I added a multiple choice field and the font doesn't show up for that either.

Sometimes changes might not reflect due to browser caching. Try to clear the browser cache or try accessing the form in an incognito window to ensure you’re seeing the most up-to-date version.

I tried that and tried Chrome, Firefox and Edge. Still no go.

After analyzing your JSON, I might try the following:

  1. Enhanced CSS: Update the CSS to ensure it has higher specificity and uses the !important flag to override any conflicting styles. This should help the font styles apply correctly to the radio buttons.

Here’s an updated CSS snippet:

"css": "/* Enhanced CSS for SingleChoice component */\n\
.plumsail-form .plumsail-radio-buttons label {\n\
    font-style: normal !important; /* Apply normal style */\n\
    font-weight: 600 !important;   /* Semibold corresponds to 600 */\n\
    color: black !important;       /* Set color explicitly */\n\
}\n"

Refined JavaScript: The JavaScript below includes a slight delay to ensure it runs after all elements are fully rendered. This may help apply the styles correctly.

"js": "fd.rendered(function() {\n\
    setTimeout(function() {\n\
        document.querySelectorAll('.plumsail-radio-buttons label').forEach(function(element) {\n\
            element.style.fontStyle = 'normal';\n\
            element.style.fontWeight = '600'; // Semibold\n\
            element.style.color = 'black'; // Set color explicitly\n\
        });\n\
    }, 500); // Slight delay to ensure elements are fully rendered\n\
});\n"

// If SharePoint Forms
"js": fd.spRendered(function() {
    setTimeout(function() {
        document.querySelectorAll('.plumsail-radio-buttons label').forEach(function(element) {
            element.style.fontStyle = 'normal';
            element.style.fontWeight = '600'; // Semibold
            element.style.color = 'black'; // Set color explicitly
        });
    }, 500); // Slight delay to ensure elements are fully rendered
});

Additional Option: If using the Type field with custom colors, adjust its configuration

{
    "type": "SingleChoice",
    "model": {
        "_internalName": "Type",
        "title": {"text": "Type of Time", "visible": true},
        "orientation": "Vertical",
        "required": true,
        "font": {"style": "Normal", "weight": "Semibold", "size": 16, "unit": "Pixel"},
        "cFont": {"style": "Normal", "weight": "Normal", "size": 12, "unit": "Pixel"},
        "cColumns": 1,
        "options": [
            {"value": "Vacation", "backgroundColor": "#37a448", "textColor": "#ffffff"},
            {"value": "Sick", "backgroundColor": "#ce310e", "textColor": "#ffffff"},
            {"value": "Birthday", "backgroundColor": "#0eaece", "textColor": "#ffffff"},
            {"value": "Work from Home", "backgroundColor": "#7b0ece", "textColor": "#ffffff"},
            {"value": "Discretionary", "backgroundColor": "#6e6e6e", "textColor": "#ffffff"},
            {"value": "Other", "backgroundColor": null, "textColor": null}
        ],
        "allowUserValue": false,
        "defaultValue": ["Vacation"]
    }
}

These snippets should be directly inserted into your JSON configuration file. The css property will handle the styling of the radio button labels, and the js property will ensure the styles are applied after the form is fully rendered. If the issue persists, try temporarily disabling other custom styles or scripts to rule out any conflicts. Sorry in advance if this does not work.

This didn't work but it was helpful in directing me to open developer tools in Chrome. The error I get points to all of the options on the page that aren't showing up. The error is "Form elements must have labels: Element has no title attribute Element has no placeholder attribute"

I also see this error: Response should include 'x-content-type-options' header.

<input type="radio" id="fd-field-a4822f6c-4fde-4bf2-8cf4-3f5e1d404207_0_0" class="custom-control-input" value="Vacation">

etc...