With Solspace Rating I'm allowing members to submit ratings in 4 rating fields. However, to some people, not all fields will apply so they can select an "N/A" option for any of the fields as needed. This option has no value ("" not "0") so it doesn't affect rating stats.
I'm using allow_unrated=""
to specify that these fields can be submitted with no value. But, I want the fields be be required - meaning they must select a valid rating (1-5) OR the "N/A" option, but they CANNOT select absolutely no option.
The trouble is, the N/A field with null value is equal to selecting nothing, which means Rating's own server-side field validation as well as my client-side form validation script think the field is empty even when it has a valid selection of "N/A".
So as far as I can figure, there's no way to allow unrated fields AND require those fields.
Setting the value of the "N/A" option to 0 is NOT a solution as that is an actual score and therefor pulls down average rating.
Here is some simplified template code for what I'd like to do (this doesn't work):
{exp:rating:form
form:class="box write-review validate"
form_name="{channel_short_name}"
collection="{channel_short_name}"
required="rating1|rating2|rating3|rating4"
allow_unrated="rating1|rating2|rating3|rating4"
allow_duplicates="no"
anonymous="no"
return="/vendor/rating-thanks/{segment_2}"
status="closed"
}
{select name="rating1"}
{option value=""}-select a rating from 1-5{/option}
{option value="1"}1{/option}
{option value="2"}2{/option}
{option value="3"}3{/option}
{option value="4"}4{/option}
{option value="5"}5{/option}
{option value=""}N/A{/option}
{/select}
{select name="rating2"}
{option value=""}-select a rating from 1-5{/option}
{option value="1"}1{/option}
{option value="2"}2{/option}
{option value="3"}3{/option}
{option value="4"}4{/option}
{option value="5"}5{/option}
{option value=""}N/A{/option}
{/select}
{select name="rating3"}
{option value=""}-select a rating from 1-5{/option}
{option value="1"}1{/option}
{option value="2"}2{/option}
{option value="3"}3{/option}
{option value="4"}4{/option}
{option value="5"}5{/option}
{option value=""}N/A{/option}
{/select}
{select name="rating4"}
{option value=""}-select a rating from 1-5{/option}
{option value="1"}1{/option}
{option value="2"}2{/option}
{option value="3"}3{/option}
{option value="4"}4{/option}
{option value="5"}5{/option}
{option value=""}N/A{/option}
{/select}
{/exp:rating:form}
At present I have to make all the rating fields not required so the form can be submitted with the "N/A" options, but then there's no way to indicate to the member that they have forgotten to select a rating for any of the fields.