2

I am using zoo visitor to register members onto a site. Some member groups are required to select their country which is saved in their entry as a category.

There is also a region field which is a sub category list linked to the country.

I have all the required field errors set inline but am not sure how I would require the country category (and if possible the region if it was present)

Here is the relevant section of my code :

{exp:zoo_visitor:registration_form return='/register/success' allowed_groups="7|8" datepicker="yes" error_handling="inline" rules:country="required"}
<label for="mobile" class="required">Mobile number:</label>
<input type="text" name="mobile" id="mobile" value="{mobile}" />
<span class="error">&nbsp;{error:mobile}</span><br>

<label for="country_of_residence" class="required">Country:</label>
<select name="category[]" id="country" class="quicksearch region_optional"> 
    <option value="">Select Country</option>  
    {exp:channel:categories category_group="1" parent_only="yes" style="linear" parse="inward"}
    <option data-name="{category_name}" value="{category_id}">{category_name}</option>
    {/exp:channel:categories}</select> 
    <br><span class="error">&nbsp;{error:country}</span>

<label for="regions" class="required">Region:</label>       
<select name="category[]" id="regions" class="quicksearch"> 
    <option value="">Select Region</option>
    {exp:channel:categories disable="category_fields" style="linear"}
    {if parent_id == '0'}{if count != '1'}</optgroup>{/if}<optgroup label="{category_name}">{/if}
    {if parent_id != '0'}<option value="{category_id}">{category_name}</option>{/if}
    {/exp:channel:categories}
    </select> <br>

{/exp:zoo_visitor:registration_form}
1
  • May I suggest that you tab your code. Will be so much easier to digest.
    – Anna_MediaGirl
    Jan 23, 2013 at 4:20

2 Answers 2

0

As inline error handling works for channel's custom fields and native fields like Title, URL title but not for category.

You should show global error messages for it like

{global_errors}{error}{/global_errors}

Hope it would help you.

0

Thanks for the suggestestions. I have decided to use jquery validation on the form instead. i think it will give me beter control over the the output.

http://github.com/posabsolute/jQuery-Validation-Engine

Demo: http://www.position-relative.net/creation/formValidator/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.