Profile Field - Select Box Issue

We have an additional profile field that is a select box which we want to be required for the customers title (i.e Mr, Mrs, Miss etc).

The first option is 'Please choose your answer' which many of our customers do not change from which is annoying especially as this is displayed on invoices.

Is there no way to have a blank option as the first variant that will trigger the required validation. This seems such a simple requirement.

I am afraid, you cannot add variants with empty name

Is this still the case with the latest versions? We are trying to add a profile Select box to the Checkout layout on version 4.17.1. The Select box appears but we cannot figure out how to require the user to select a value other than the first one which is selected by default and contains the text “Please select”. If this is not possible it would really be a nice option to allow users to create Select boxes with an option to require a value other than the first.

I realized that there was a later post on this subject = Profile Fields: Select Box Default Value

However, the suggested code change made no difference, and I found that the template code was not even correct since $field.required does not contain a value.

So to accomplish what I think I want, I made the following change in the field.tpl. The first if (checkout_required = N) triggers the code block that already existed while the second if (checkout_required = Y) triggers the change that I want to see.

{if $field.checkout_required == "N"}
	{if $field.required == "YesNo::NO"|enum}
		<option value="">--</option>
	{/if}
	{foreach $field.values as $value => $name}
		<option {if $field_value == $value}selected{/if} value="{$value}">{$name}</option>
	{/foreach}
{/if}
{if $field.checkout_required == "Y"}
	<option selected value="">Please Select...</option>
	{foreach $field.values as $value => $name}
		<option value="{$value}">{$name}</option>
	{/foreach}
{/if}
3 Likes