RequiredFields does not display a message if the FileAttachmentField is required
Opened this issue · 7 comments
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.
Same issue, is there a solution on the way?
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 %>
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
`
<% 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 %>
<% if $IsMultiple && $CanUpload %>
<%t Dropzone.ATTACHFILESHEREOR "Dra en eller flera filer hit eller" %>
<% else_if $CanUpload %>
<%t Dropzone.ATTACHFILEHEREOR "Dra en fil hit eller" %>
<% end_if %>
<% if $CanUpload && $CanAttach %>
<% end_if %>
<% if $CanUpload || $CanAttach %>
<% if $CanUpload %>[<%t Dropzone.BROWSEYOURCOMPUTER "browse your computer" %>]<% end_if %>
<% if $CanUpload && $CanAttach %> <%t Dropzone.OR " or " %> <% end_if %>
<% if $CanAttach %>[<%t Dropzone.CHOOSEEXISTING "choose from existing files" %>]<% end_if %>
<% 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>
`
Thanks for this, everyone. Can someone please submit the necessary update as a PR?
I added it as part of this PR: #59
@unclecheese Can you please close this?