Last post Oct 24, 2008 03:52 PM by tgmdbm
Oct 24, 2008 04:25 AM|sia123|LINK
Let's say I have the following HTML:
Everything is fine when the view is loaded, the correct value from the model is matched against one of the radio buttons and the correct one is selected/checked. When viewed the source of the HTML generated each checkbox has correct value: one "true" the
However when the view form is posted and inside the action you do a
call, and the view is re-displayed (due to other validation errors). Both of the above radio buttons will have the same value, which is the attempted value that you posted. For example, if YES was selected then the value re-rendered for both above radion
buttons is "true".
Consequently I looked at the code for Input Checkbox extension. If you look at InputHelper extension (MVC Beta) method in
you notice the lines:
I believe where it is coded: if (isCheckBox) it should instead be:
if (isCheckBox || isRadio)
As even the comment in the existing code suggests that for radio buttons it should also behave like checkboxes. As it doesn't make sence for all radio buttons with the same name to use the same attempted value as that would cause problems when the form is
re-submited as this time all values are the same and cannot be distinguished.
Am I correct to assume that the above is a bug? That indeed it should be
if (isCheckBox || isRadio). Has anyone has a explanation that it should be like it is in the current code and that I should be doing
Since the above has been agreed that is a bug. I've built a new version of the MVC with the change above [ changed
if (isCheckBox) to if (isCheckBox
|| isRadio) ]. With this new build I've had no issues (and without any side effects). I'm using this workaround until the next version of the MVC is released.
Oct 24, 2008 03:52 PM|tgmdbm|LINK