silverstripe-dropzone icon indicating copy to clipboard operation
silverstripe-dropzone copied to clipboard

RequiredFields does not display a message if the FileAttachmentField is required

Open nimeso opened this issue 10 years ago • 7 comments
trafficstars

FileAttachmentField::create('Image', '') $validator = new RequiredFields('Title','Image')

It does not let me save the object but gives no message or indication that I need to upload a file.

nimeso avatar Oct 27 '15 22:10 nimeso

Same issue, is there a solution on the way?

mrguits avatar Jan 11 '16 16:01 mrguits

Solution:

There is no $Message variable in the FileAttachmentField_holder.ss template

You need to add <% if Message %>$Message<% end_if %>

This is the top of my template:

<% if $Title %><label class="left" for="$ID">$Title</label><% end_if %>
<% if $LeftTitle %><div class="subtitle"> $LeftTitle </div><% end_if %>
<% if $Description %><div class="subtitle"> $Description </div><% end_if %>
<% if Message %><span class="help-block $MessageType">$Message</span><% end_if %>
............................................. ............................................. .............................................

mrguits avatar Jan 12 '16 09:01 mrguits

Hello, I have the same problem and i tried to add <% if Message %>$Message<% end_if %> at the top of the template but nothing happened...Could you be more specific please? Thank you

tomzi avatar Sep 05 '16 11:09 tomzi

`

<% if $Title %><label class="left" for="$ID">$Title</label><% end_if %>
<% if $LeftTitle %><div class="subtitle"> $LeftTitle </div><% end_if %>
<% if $Description %><div class="subtitle"> $Description </div><% end_if %>
<% if Message %><span class="help-block $MessageType">$Message</span><% end_if %>


[] []

    </p>
    <ul data-container data-attachments class="file-attachment-field-previews $View">
        <% if $AttachedFiles %>
            <% loop $AttachedFiles %>
                <% include FileAttachmentField_attachments File=$Me, Scope=$Up %>
            <% end_loop %>
        <% end_if %>
    </ul>
    <template>
        $PreviewTemplate
    </template>
    <div class="attached-file-inputs" data-input-name="$InputName">
        <% if $AttachedFiles %>
            <% loop $AttachedFiles %>
            <input class="input-attached-file" type="hidden" name="$Up.InputName" value="$ID">
            <% end_loop %>
        <% end_if %>
    </div>
    <div class="attached-file-deletions" data-input-name="$InputName"></div>
    <div style="clear:both;"></div>
    
    <% if not $AutoProcess %>        
        <button class="process" data-auto-process><%t Dropzone.UPLOADFILES "Upload file(s)" %></button>
    <% end_if %>
</div>
<div class="unsupported">
    <p><strong><%t Dropzone.NOTSUPPORTED "Your browser does not support HTML5 uploads. Please update to a newer version." %></strong></p>
</div>

`

mrguits avatar Sep 05 '16 11:09 mrguits

Thanks for this, everyone. Can someone please submit the necessary update as a PR?

unclecheese avatar Sep 06 '16 01:09 unclecheese

I added it as part of this PR: https://github.com/unclecheese/silverstripe-dropzone/pull/59

silbinarywolf avatar Oct 04 '16 02:10 silbinarywolf

@unclecheese Can you please close this?

silbinarywolf avatar Jul 07 '17 00:07 silbinarywolf