Can't submit the SMS provider settings form without empty provider but can't set Twilio until I submit the form
Describe the bug
After enabling the SMS Notifications feature I wanted to set Twilio as the default provider. For that, first, I needed to enable it on the same form where the default provider is needed to be set. However, I can't save it without selecting any provider. It can be worked around if there an option selected until I save the form and Twilio is enabled, then select Twilio, however, if there's nothing in there (e.g., in production), then there is no way to save the form. Locally, the "Log" is an option, but in prod, there's nothing in the list.
Orchard Core version
2.0.2
To Reproduce
- Enable "SMS Notifications"
- Go to Configuration > Settings > SMS
- Notice that Twilio is no in the Default Provider list, and nothing is selected.
- Go to Twilio tab.
- Enable Twilio and fill the form.
- Click Save.
- See validation error that Default Provider is not selected.
Expected behavior
Maybe the Default Provider shouldn't be a mandatory field? Or some JS code that adds Twilio to the list right after checking the Enable Twilio checkbox?
Workaround
- If there is at least one other item in the Default Provider list, then select that. After enabling Twilio, replace it with that.
- If there is no other, then create a temporary one from code like this, and do the same as above:
public class DummySmsProvider : ISmsProvider
{
private readonly IStringLocalizer<DummySmsProvider> T;
public LocalizedString Name => T["Dummy SMS Provider"];
public DummySmsProvider(IStringLocalizer<DummySmsProvider> localizer) => T = localizer;
public Task<SmsResult> SendAsync(SmsMessage message) => throw new System.NotImplementedException();
}
services.AddSmsProvider<DummySmsProvider>(nameof(DummySmsProvider));
There's a 'LogSmsProvider OOB, that could be used or set Twillio by default
We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).
This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.
@barthamark anything to add here?
I don't have anything to add here, I'd say it's still a good idea to fix it even if the LogSmsProvider is still there (which is not the case in some cases).
What's your proposed fix?
My proposed fix is what I wrote to the expected behavior. Somehow either separate the form pages and their validation. I want to be able to save the form on the Twilio tab with the Enable switch set to ON without setting any provider on the first tab (obviously, my next step would be to set that to Twilio). Or just not make the provider a required field.