Hi,
I have a dropdownField case with two buttons:
a!dropdownField( label: "Field", labelPosition: "ADJACENT", placeholderLabel: "--- Select a Value ---", choiceLabels: {1,2,3,4}, choiceValues: {1,2,3,4}, validationGroup: "Submit", validations: {"some warning message"}, saveInto: ri!test, value: ri!test, required: true )
One button is "Submit", with validationgroup when I did not the select an value, it will have required message.
Another button is "Publish", which was not bundled the validationGroup, if I did not select one, and left it as null, and click Submit button directly, the required message did not come out, but I still need this null validation.
Anyone know how to handle my case? Thanks.
Discussion posts and replies are publicly visible
Personally I've always found the validationgroup functionality a bit counterintuitive. It has never quite worked as I'd expect for any of my use cases. And then there's the issue where using it on a "required" field removes the "required" indicator no matter what else you do.
My best advice is, usually, to consider another implementation strategy. My favorite is a combination of vanila validations and disabling/enabling buttons based on on-form conditions, like whether a certain value is null, etc.
If you insist on going forward using validationGroups, however, you might actually have some luck by just controlling what the validationGroup text value is - i.e. if the dropdown is empty, make the validationGroup text blank, otherwise make it belong to the "submit" group. I don't guarantee that this is a finished and working solution, just my best guess as to a good starting point for your use case.
Edit: I've modified Krishna's example from above and added my suggestion - this is on the simpler side but it seems to do essentially what you want.
load( local!test, a!formLayout( label: "Example: ", contents: { a!dropdownField( label: "Field", labelPosition: "ADJACENT", placeholderLabel: "--- Select a Value ---", choiceLabels: { 1, 2, 3, 4 }, choiceValues: { 1, 2, 3, 4 }, validationGroup: if( isnull(local!test), null(), "Submit" ), requiredMessage: "A selection is required.", saveInto: local!test, value: local!test, required: true() ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Publish", submit: true ), a!buttonWidget( label: "Submit", style: "PRIMARY", submit: true, validationGroup: "Submit" ) } ) ) )
Thanks Schmitt, very glad to see your answer, same as I just done.