Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FileItem validation with maxFileSize

    I am using a DynamicForm with a FileItem field for file upload. Here is my DataSource descriptor:

    <DataSource ID="uploadFile" serverType="generic">
    <fields>
    <field name="fileName" type="binary" maxFileSize="1024" title="Choose File" required="true"/>
    <field name="override" type="boolean"/>
    </fields>
    <serverObject className="MyDMI" />

    </DataSource>

    When I attempt to upload a file exceeding maxFileSize, I indeed get an error message set on the field, however, I need to determine if the form is valid in my code. When I execute

    form.saveData(callback);
    Map errors = form.getErrors();

    The errors Map is empty. If I use form.validate() instead, it returns true, even though I expect it to be false. Please help.

    #2
    Validation in this case involves a server trip, so you cannot make an immediate call, you must use the callback.

    To make sure the callback fires even if the save fails, set willHandleError:true via the requestProperties argument of saveData().

    Comment


      #3
      Thank you so much, that worked beautifully!

      Comment

      Working...
      X