0

I have a channel form so logged-in members in a specific group can create and edit channel entries. One of the fields is a file upload field.

I have it set as a required field but the file field isn't showing an error if there is no file uploaded. Other required fields are.

I've tried it with errors inline and through the default template. Does anyone have some template code with this working?

EE 2.9.2

Update.

I have set-up a hugely simplified template to test.

<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <link href="{site_url}themes/cp_themes/default/css/channel_form.css" type="text/css" rel="stylesheet" media="screen">
    <script type="text/javascript" src="{site_url}assets/js/jquery-1.7.2.min.js"></script>
</head>
<body>
    {exp:channel:form
        channel="{segment_3}"
        entry_id="{segment_4}"
        include_jquery="no"
        status="pending"
        return="applications"
        rules:cf_appli_photograph="required"
        }

        {!-- set author as current logged-in member - uses https://devot-ee.com/add-ons/channel-form-author --}
        <input type="hidden" name="cfaid" value="[{member_id}]"/>

        {!-- set title of entry as member id and time --}
        <input type="hidden" name="title" id="title" value="{member_id} {current_time format="%d %m %Y %H:%i"}">

        <fieldset>

            <label for="cf_appli_photograph">Photograph</label>
            <p class="help">Max 1Mb</p>
            {field:cf_appli_photograph}
            {if error:cf_appli_photograph}
                <p class='alert-error'>{error:cf_appli_photograph}</p>
            {/if}

        </fieldset>

        <input type="submit" value="Submit">
    {/exp:channel:form}
</body>
</html>

If the image size exceeds the Maximum File Size set in the File Upload Preferences I get an error saying so.

If there is no file included at all the form successfully submits although the field is set as required.

No Console errors.

Apologies for the slow reply and thanks for taking a look.

3
  • Can you post your channel entries form template code? I'd like to help you.
    – jrothafer
    Jun 30, 2015 at 0:24
  • AS JChrono says, an example snippet would be great! Failing this can you confirm that you are loading the relivent Javascript on your channel form page? The File field from EE requires its JS to work properly. Could be a shot in the dark just mentioning a common pit-fall!
    – Blatant
    Jun 30, 2015 at 14:46
  • Updated with template code.
    – Tim Print
    Jul 2, 2015 at 15:11

0

Your Answer

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

Browse other questions tagged or ask your own question.