-
Notifications
You must be signed in to change notification settings - Fork 1
Code Reference
Manages form submission and is intended to contain the form elements and contains the is_input() method.
submit_button
: Submit
Calls the submit()
function when pressed.
protocol
: Protocol
Handles the submission of the form.
Submits the form data to the protocol if the data is valid.
-> Dictionary
Generates a dictionary of the form data.
If a key with the same name already exists, the instance id is joined with an underscore to the key.
Example of a key with instance id: "Input_29460792527"
-
include_labels
:=false
if include_labels:
return { { "label": ..., "input": ... }, ... }
else:
return { input, ... }
-
subject
:Node
=self
The node to generate the dictionary from.
This is mainly used for recursion. -
fields
:={}
The dictionary to add the fields to.
This is mainly used for recursion.
-> StringName
Generates a unique key for the subject to be used in the object.
-
subject
:Node
-
object
:Dictionary
-> bool
Returns whether the given node is an input.
Inputs are:
- buttons except MenuButton
- LineEdit
- TextEdit
- ItemList
- Slider
- SpinBox
- GraphEdit
-
subject
:Node
Button that submits the form data.
This class only exists to avoid having to rename a button and to have an icon in the editor
LineEdit with a validator
validator
: Validator
Assigns the style from the validator if it exists.
TextEdit with a validator
validator
: Validator
Assigns the style from the validator if it exists.
Label for input controls
Path to input control
Allowed types:
CheckBox
CheckButton
OptionButton
Submit
LineEdit
TextEdit
ItemList
Slider
SpinBox
GraphEdit
Internal storage for input_path
Input control to label
Must be an input according to Form.is_input
or null
Input must not be empty
The style to apply to the input if invalid
The style to apply to the input if valid
Internal storage for valid_style
String to append to label if input_required
- SEPARATE
Display the text as thelabel.text
- IN_INPUT
Hide the label and overwriteinput
.placeholder_text
or for lack thereof,input.text
- HIDDEN
Hide the label
How to display the label
-> void
Sets the label text to the input's name if it is empty and connects signals
-> void
Update label display mode based on visibility
- If the label is visible and the mode is either
Mode
.IN_INPUT
orMode
.HIDDEN
, the mode is set toMode
.SEPARATE
. - If the label is not visible and the mode is
Mode
.SEPARATE
, the mode is set toMode
.HIDDEN
. - Else the mode setter is run (
mode = mode
).
-> void
Add or remove the required_hint if input_required
-> bool
Change style based on validity and return validity or default if input is not validatable
-> void
Indicate validity when the input node recieves a GUI input
default
:= true
the default value to return if input is not validatable
-> bool
Return validity of "Subject has property_name and it is not a method"
subject
:= Object
property_name
:= String
-> void
Indicate validity on GUI input if event is relevant and validate_on_input
event
:= InputEvent
Handles form submission and response.
-> int
Submits form data and returns HTTP status code of the response.
-
fields
:Dictionary
The output ofForm.generate_fields_dict
-> Variant
Finds the value of the given Node based on its type.
Throws an error if the type is unknown.
BaseButton
-> button_pressed
: bool
LineEdit
| TextEdit
-> text
: String
Slider
| SpinBox
-> value
: float
GraphEdit
-> get_connection_list()
: Array[Dictionary]
ItemList
-> items
:
Array[{
selected = is_selected(): bool,
text = get_item_text(): String,
icon = get_item_icon(): Texture,
metadata = get_item_metadata(): Variant
}]
Validates Text Input according to rules about length and content.
A collection of predefined regular expression patterns.
Items correspond to the PredefinedRegex
Input must have a value.
min_length
will be adjusted if needed.
temporary storage of min_length used by the setter of required
Minimum length of the input.
word_range
: Boundaries
Minimum and Maximum number of matches for \w+ allowed
whitelist
: ListFilter
List of allowed strings.
blacklist
: ListFilter
List of prohibited strings.
- NONE
- ALPHABETICAL
- NUMERICAL
- ALPHANUMERICAL
- EMAIL_ADDRESS
- PHONE_NUMBER
Predefined pattern to match against.
- MUST_MATCH_BOTH
Input must match both the predefined and the custom regex (if both are set) - CAN_MATCH_EITHER
Input can match either the predefined or the custom regex (if at least one is set)
How predefined and custom regexes are checked against in relation to each other.
Custom Pattern to match against.
Normalise the case before matching.
Don't allow any more than one match.
-> void
Compiles the custom regex
-> void
Validates given text and updates valid property.
-
new_text
:String
New content of the input
-> bool
Validates given text against all rules and returns validity
-
subject
:String
Text to validate
An upper and lower bound of an integer value.
Lower bound
Upper bound
-> bool
Determines if the subject is within the boundaries.
-
subject
:int
A filter with a blacklist or whitelist of strings
- ALL
All elements must be present - AT_LEAST_ONE
At least one element must be present
Match requirement
The blacklist or whitelist
-> bool
Returns wether the subject is represented in the list
-
subject
:String
-> int
Returns the output of elements.size()
FileProtocol
: Protocol
Handles form submission to a JSON file.
Directory to save responses to.
File name scheme. Available variables:
-
{hash}
: Hash of the form data. -
{id}
: Number of existing files in the target directory + 1. -
{year}
: Current year. -
{month}
: Current month. -
{day}
: Current day. -
{weekday}
: Current weekday. -
{hour}
: Current hour. -
{minute}
: Current minute. -
{second}
: Current second.
-> int
Saves form data to a new file according to the file_name_scheme
and returns 200.
-
fields
: Dictionary - The output ofForm.generate_fields_dict()
.
NetworkProtocol
: Protocol
Handles form submission and response over the network.
Target hostname
Target port -1 means "use default port"
Use authentication for target
Username at target
Password at target
Path to private key file
-> void
Tries to set host_username
based on environment var, if not already set.
HttpProtocol
: NetworkProtocol
Handles form submission and response over the network using HyperText Transfer Protocol
Web export is not supported.
Based on tutorial Godot Docs > Tutorials > Networking > HTTP Client Class
Use HTTPS
Target path
- GET
- HEAD
- POST
- PUT
- DELETE
- OPTIONS
- TRACE
- CONNECT
- PATCH
HTTP Method
HTTP Headers
HTTP Client
{protocol}://{host}
-
code
:int
HTTP Status Code -
headers
:Dictionary
-
body
:PackedByteArray
-> void
Sets the port to 443 if encrypt
is true, otherwise 80, if it is set to -1.
Submits form data and returns HTTP status code of the response.
Web export is not supported.
-
fields
:Dictionary
-> String
Returns a string representation of the HTTPClient.STATUS_. or "Status: {status}" if the status is not one of the following:
2. Error resolving host {host}
4. Error connecting to host {host}:{port}
8. Error in HTTP connection
9. Error in TLS handshake
-
status
:int
Status returned by HTTPClient.get_status()
MailProtocol
: NetworkProtocol
Handles form submission and response over the network using E-Mail.
- HTML
Stylable HyperText Markup Language Form with disabled inputs - PLAIN_TEXT
{key}: {value} - JSON
JavaScript Object Notation
Path to CSS file to use for styling regardless of body_format
Sender name
Sender address
Recipient address
Subject line
-> int
Submits form data in an E-Mail to the recipient and returns HTTP status code of the response.
-
fields
:Dictionary
-> String
Generates the body for the E-Mail
-
fields
:Dictionary
Output of Form.generate_fields_dict() to populate body
-> String
Converts a type to a string for use in HTML form.
TYPE_STRING -> "text"
TYPE_BOOL -> "checkbox"
TYPE_INT -> "number"
TYPE_FLOAT -> "number"
TYPE_ARRAY -> "select"
TYPE_NIL -> "text"
-
type
:int
Output of typeof()
-> String
Returns the value of a node as a string for use in the E-Mail body.
-
subject
:Node
SmtpMailProtocol
: MailProtocol
Handles form submission and response over the network using Simple Mail Transfer Protocol
- NONE
- SSL
- TLS
Security Type Adjusts the port if it is 0, 465 or 587.
Authenticate with the mail server
Username at the mail server
Password at the mail server
-> void
Sets the port based on the security type if it is -1.
-> int
Returns handle_smtp(generate_body(fields)).
-
fields
:Dictionary
Output of Form.generate_fields_dict() to populate body
-> int
Handles the SMTP request and returns the status code.
-
body
:String
E-Mail body
MailsendSmtpMailProtocol
: SmtpMailProtocol
Handles form submission and response over the network using mailsend.
Mailsend must be installed.
Print debug messages
Verify the certificate in connection
Write log messages to this file
-> int
Calls mailsend with the given body and parameters based on the properties and returns the status code.
-
body
:String
E-Mail body