Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Checkboxes 'other-choice-text' field disappears when a different checkbox is selected - MVC forms #2163

Copy link
Copy link
@Superhands89

Description

@Superhands89
Issue body actions

Using a Sitefinity MVC form with the Checkboxes control and the "other" option active, if the user selects the "other" option the other input field shows.
But if the user then also selects another option, the "other" input field disappears despite remaining checked.

image
image

I suggest maybe adding !otherCheckbox.is(':checked') to the checkboxClickHandler function in form.all.js as shown below...

var checkboxClickHandler = function (e) {
    var container = $(e.target).parents('[data-sf-role="checkboxes-field-container"]');
    var checkboxes = container.find('input[data-sf-role="checkboxes-field-input"]');
    var otherInput = $(container.find('[data-sf-checkboxes-role="other-choice-text"]').first());
    var otherCheckbox = $(container.find('[data-sf-checkboxes-role="other-choice-checkbox"]').first());
    var otherCheckboxIndex = checkboxes.index(otherCheckbox);
    var currentIndex = checkboxes.index($(e.target));
    var isRequired = container.find('[data-sf-role="required-validator"]').val() === 'True';

    if (currentIndex == otherCheckboxIndex && otherCheckbox.is(':checked')) {
        otherInput.attr('type', 'text');

        if (isRequired)
            otherInput.attr('required', 'required');
        else
            otherInput.removeAttr('required');
    }
    else if (!otherCheckbox.is(':checked')) { // Modified
        otherInput.attr('type', 'hidden');
        otherInput.removeAttr('required');
    }
};
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.