I can't remember whether I raised this as an issue or not (I couldn't find it) but there is still an issue with validation on SelectList as the following won't compile:
<Validation Validator="@SelectListValidator.Validate">
<SelectList Data="@studiesList" TextField="@((item) => item?.StudyName)" ValueField="@((item) => item?.StudyId)" SelectedValue="@allocation.StudyId" SelectedValueChanged="@(e => { allocation.StudyId = System.Convert.ToInt32(e); } )">
<Feedback>
<ValidationError />
</Feedback>
</SelectList>
</Validation>
If I remove the
It's because SelectList does not have any validation, but Select(Edit) that is inside of it has. Also Feedback is placed inside of Select component. So your Feedback should actually be passed to the underline Select or maybe you can remove it from SelectList.
Try this
<Validation Validator="@SelectListValidator.Validate">
<SelectList Data="@studiesList" TextField="@((item) => item?.StudyName)" ValueField="@((item) => item?.StudyId)" SelectedValue="@allocation.StudyId" SelectedValueChanged="@(e => { allocation.StudyId = System.Convert.ToInt32(e); } )">
<ValidationError />
</SelectList>
</Validation>
Removing the Feedback tag does allow it to compile, and an "X" is displayed correctly. But how do I show the error message "Study is required" under the component like I would for a TextEdit component?
Well internally Feedback is used as a placeholder for validation messages so it's placed at the right place for every supported CSS provider. Try moving ValidationError /> outside of SelectList. If that doesn't help I will try to do a quick fix.
Moving ValidationError to under the SelectList does fix this problem - thanks!
Most helpful comment
Moving ValidationError to under the SelectList does fix this problem - thanks!