In Freeform I use the loop to display all my fields:

        <!-- place holder for ajax errors-->
        <div class="error_message"></div>

how can I display an asterix beside fields which are required? Form called and required fields displayed like:


1 Answer 1


You've hard-coded the required fields in the template by including them in the template tag, so why not hard code it in your loop?

    {if freeform:field_name == "business_name" 
        || freeform:field_name == "business_category"
        || freeform:field_name == "contact_person" 
        || freeform:field_name == "email_address"}
        <span class="required">*</span>

I didn't say it was a great solution! In the docs there's no mention of freeform:field_required variable :(

I'd strongly recommend you use the Composer though - especially as you have the Pro version. It is really great, and you can create a template that is fully flexible for any type of form your editor/admin wants to create. And it has a variable to detect if a field is required. So nothing is hard coded in the template! See an example here, or you want more example code, raise another question.

  • I already had the form done in Composer but changed to the Form and Ajax submission as I wanted the form to retain the values when the user made an error. In composer when there was an error the form was blanked.
    – mmc501
    Commented Feb 8, 2016 at 12:34
  • Thought you went down the Ajax route to solve that?: expressionengine.stackexchange.com/questions/35474/… - You an still use Ajax with Composer. Commented Feb 8, 2016 at 12:39
  • Ah I did - but used the example in the docs on their website which used the standard form - never thought of the Ajax with Composer - that would have been the best solution!
    – mmc501
    Commented Feb 8, 2016 at 12:42

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.