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

Only required if wizard page edited #11

Open
markeaston63 opened this issue Nov 2, 2023 · 2 comments
Open

Only required if wizard page edited #11

markeaston63 opened this issue Nov 2, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@markeaston63
Copy link

markeaston63 commented Nov 2, 2023

Is your feature request related to a problem? Please describe.
We have wizard pages that have required fields only if the form is edited. Eg for a "Primary Contact" the user can choose to enter one in or not. If the user starts entering in the First Name or Last Name etc then the required fields are activated. I call it "onActiveRequired". In the case of the Primary Contact form the required fields become First Name, Last Name, Location and Email.

Id like to code this into a PR or a fork - whichever you prefer.

Describe the solution you'd like
I have already coded it in our copy of your code.
A field is given a class of "on-active-required".
In formValidator we check for "required" and "on-active-required"
if (check) {
pageIsActive = true
} else {
onPageActiveTarget.push(e)
check = true;
}
After we have processed the entire form we see if pageIsActive is true
If it is true we add the fields in the onPageActiveTarget array to the target array (ie they are now required as the form has had data entered in.

Also need to change dispatchInput ... (and pass true or false to it as required)

dispatchInput: function (wz_content, isRequired, e) {
    let type = e.getAttribute("type");
    if (!isRequired && e.value === "")
    {
        return true;
    }

Works beautifully - QA has already tested it here.

Describe alternatives you've considered
None that I could think of. I would endeavour to recode the above as nicely as possible. Think of some way to split the functionality in some way to another method to make it read better.

Additional context
I also have a related feature we need. If we have two fields on a form. One a drop down and one a text field. If a certain value is selected in the drop down then the text field becomes mandatory. These are common features we have in all our wizards so would rather code it once in the wizard.

What do you think? If you give me the all clear - I will code up both features as two PRs immediately.

@markeaston63
Copy link
Author

markeaston63 commented Nov 2, 2023

We are likely to need quite a few features added to your wizard over time. We are very happy to work with you. This is who we are: www.naverisk.com. Great component by the way. Cheers

@AdrianVillamayor AdrianVillamayor self-assigned this Nov 4, 2023
@AdrianVillamayor AdrianVillamayor added the enhancement New feature or request label Nov 4, 2023
@markeaston63
Copy link
Author

Hi Adrian,

I have the enhancement coded - but I need a branch please.

Mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants