struct DynFork::Fields::FileField

Overview

File upload field.

NOTE How to use, see example.

Defined in:

dynfork/fields/file.cr

Constructors

Instance Method Summary

Instance methods inherited from struct DynFork::Fields::Field

choices_from_json(json : String) : Nil choices_from_json, disabled=(disabled : Bool) disabled=, disabled? : Bool disabled?, errors : Array(String) errors, errors=(errors : Array(String)) errors=, field_type : String field_type, group : UInt8 group, hide=(hide : Bool) hide=, hide? : Bool hide?, hint : String hint, id : String id, id=(id : String) id=, ignored? : Bool ignored?, label : String label, name : String name, name=(name : String) name=, slug_sources : Array(String) slug_sources, warning : Array(String) warning, warning=(warning : Array(String)) warning=

Constructor methods inherited from struct DynFork::Fields::Field

new(pull : JSON::PullParser) new

Constructor Detail

def self.new(pull : JSON::PullParser) #

[View source]
def self.new(label : String = "", default : String | Nil = nil, target_dir : String = "files", accept : String = "", placeholder : String = "", maxsize : Int64 = 2097152, hide : Bool = false, required : Bool = false, disabled : Bool = false, readonly : Bool = false, ignored : Bool = false, hint : String = "", warning : Array(String) = Array(String).new) #

[View source]

Instance Method Detail

def accept : String #

HTML attribute: accept
Describing which file types to allow.
Example: ".pdf,.doc,.docx,application/msword"

NOTE https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers


[View source]
def default : String | Nil #

Default file path.
Example: "public/media/default/nodoc.docx"


[View source]
def default? : String | Nil | Nil #

Default file path.
Example: "public/media/default/nodoc.docx"


[View source]
def extract_file_data? : DynFork::Globals::FileData | Nil #

[View source]
def extract_file_path? : String | Nil #

[View source]
def field_type : String #

Field type - Structure Name.


[View source]
def from_base64(base64 : String | Nil = nil, filename : String | Nil = nil, delete : Bool = false) : Nil #

Convert base64 to a file and save in the target directory. filename: Example: foo.pdf


[View source]
def from_path(path : String | Nil = nil, delete : Bool = false) : Nil #

Convert path to a file and save in the target directory.


[View source]
def group : UInt8 #

To optimize field traversal in the paladins/check() method.

WARNING It is recommended not to change.


[View source]
def input_type : String | Nil #

Html tag: input type="file".


[View source]
def input_type? : String | Nil | Nil #

Html tag: input type="file".


[View source]
def maxsize : Int64 #

The maximum allowed file size in bytes.

NOTE 1 MB = 1048576 Bytes (in binary).


[View source]
def media_root : String #

Root directory for storing media files.


[View source]
def media_url : String #

URL address for the media directory.


[View source]
def placeholder : String #

Displays prompt text.


[View source]
def readonly=(readonly : Bool) #

Specifies that the field cannot be modified by the user.


[View source]
def readonly? : Bool #

Specifies that the field cannot be modified by the user.


[View source]
def refrash_val_file_data(val : DynFork::Globals::FileData) : Nil #

[View source]
def required? : Bool #

Required field.


[View source]
def target_dir : String #

Directory for files inside media directory.
Examples: files|resume|reports


[View source]
def value : DynFork::Globals::FileData | Nil #

Sets the value of an element.


def value=(value : DynFork::Globals::FileData | Nil) #

Sets the value of an element.


[View source]
def value? : DynFork::Globals::FileData | Nil | Nil #

Sets the value of an element.