File Upload Fields
If you need to collect uploaded file data then you can use ASP.NET Core MVC's IFormFile
type for your model property, e.g.:
public IFormFile FileUpload { get; set; }
In order for file uploads to work you will need to set the encoding type on the form to multipart/form-data
(as opposed to the default), e.g.:
<chameleon-form enctype="Multipart">
@* ... *@
</chameleon-form>
To then use the file upload in your controller action you use the documented approaches to handle the uploaded file(s). If you want the field to be Required you can annotate with [Required]
.
ChameleonForms doesn't currently support generating the correct HTML to handle multiple file uploads, but feel free to submit an issue or pull request to discuss adding that feature.
Default HTML
When using the Default Field Generator then the default HTML of the Field Element will be:
<input %validationAttrs% %htmlAttributes% id="%propertyName%" name="%propertyName%" type="file" value="%value%" />
If the field is marked as [Required]
then required="required"
will be added.