The library functions using a /Form datum, this datum contains various procs and vars that make your life using forms much, much easier.
First lets take a look at the form datum's variables.
submit (Default: "Submit")
This variable will contain the text to be displayed on the form's submit button.
reset (Default: "Reset")
This variable will contain the text to be displayed on the form's reset button.
form_url (Default: null)
This variable tells the form where to send its data when submitted (the form's action parameter).
form_sub_path (Default: null)
This variable contains any extra path information that is to be passed through the form, any text in this variable will be appended to the end of the form_url.
form_title (Default: null)
This variable contains any text you wish to pass to the 'title' parameter of your form.
form_window (Default: null)
If you have any extra browse() data you wish to pass this is how you do it, this variable is basically the same as the second argument of browse().
form_reusable (Default: null)
When set this variable will allow the user to submit the same form more than once, otherwise the form will expire and cannot be sent again.
form_cgi_mode (Default: null)
This variable tells the form whether it should be processed by client.CGI or not. This is automatically set when used in CGI mode.
form_method (Default: "get")
This variable sets the 'method' parameter of your form, the most common values are 'get' and 'post'. When using forms in Dream Seeker the method MUST be 'get' otherwise the form won't submit.
form_extra (Default: null)
The procs and how to use them
Calling this proc with a mob argument will cause your form to be displayed to that mob.
var/Form/my_form/frm = new()
Calling this function will force the Form datum to submit its data with. The 'href' parameter contains any extra data you want to pass through.
var/Form/my_form/frm = new()
Calling this will return a friendly URL with all of your form parameters intact. (eg: http://myurl.com/mypage.dmb?form=/Form/ my_form¶m=somevalue)
This proc is called when DisplayForm() is called, it is most useful for detecting when a certain form has been loaded.
world << "My form has been displayed!"
This proc is called when the form is finished processing. Useful for detecting when data has been successfully passed.
world << "My form has finished processing!"
This proc is used to determine the HTML layout of the form.
Please submit this value: [some_input]<br>
This example shows how to display an input box with your own text, as well as the submit and reset buttons.
As anyone who's ever used a HTML form before knows, there are many input types, not just text fields. This section will explain how to make use of the _interface setting for form variables.
password_input_interface = PASSWORD
Notice how I used the variable password_input_interface, this tells the system to check for a variable called password_input and change the input type of it to 'password'. This works for many different types of inputs.
Here is a list of all of the valid _interface types avaliable:
TEXT -- This is the default value, a simple text input.
PASSWORD -- A masked input for passwords.
TEXTAREA -- A multi-line text input, you can also set the _size of a variable to use this type.
big_input_size = "10x10"
This will make big_input a 10x10 textarea.
SELECT -- A simple single selection input. Any variable with _values will be set to this type.
select_input_values = list("One","Two","Three")
This will create a selection box with the three values included.
MULTI_SELECT -- This is the same as SELECT except it allows the user to select more than a single item.
CHECKBOX -- This creates a checkbox. When checked the variable will be true (1), if not it'll be false (null/0)
CHECKLIST -- This allows you to group checkboxes together so that their values are passed back as a _values list.
checklist_input_interface = CHECKLIST
checklist_input_values = ("One","Two","Three")
for(var/V in checklist_input_values)
world << "[V] = [checklist_input_values[V]]"
This will output something similar to 'One = 1' 'Two = 0' and so on, depending on the checked value of the boxes in the list.
RADIO -- This creates a radio box, this interface isn't meant to be used on its own, a few variable control types are included to allow for its use.
radio_input_interface = RADIO
radio_input_1 = "One"
radio_input_2 = "Two"
radio_input_3 = "Three"
This will create three radio boxes in the same group, only one of the three can be selected at any time.
RADIO_LIST -- This works exactly like CHECKLIST except with radio inputs.
HIDDEN -- This allows you to make a hidden form element, this element won't be displayed on the form.
BUTTON -- This allows you to create a custom button. To interact you simply define a proc like varClick().
button_input = "My Button"
button_input_interface = BUTTON
usr << "You clicked the button!"
PROMPT -- This works just like BUTTON except the return value of whatever you prompt the user for (file, icon, whatever) is returned by the Click() call instead of it just being called.
PROMPT_FOR_(SOUND/ICON/FILE) -- The same as PROMPT except all of the dialog input is handled for you.
SUB_FORM -- This allows you to include another /Form datum to be processed along with the parent form.
sub_form = /Form/other_form
sub_form_interface = SUB_FORM
Special variable amendments
As I noted in the previous section there are special amendments to variables you can use such as _interface and _size. This section will go over the ones I haven't mentioned yet.
_maxlen When used on a text input this will control the maximum length the user can input into said control.
_validate This controls whether variables using the _values system will validate their values before processing and return an error if a value is considered incorrect. It is on by default.
_hidden This works a lot like the HIDDEN interface except that variables with _hidden are automatically placed even if you override HtmlLayout().
_wrap This controls the wrapping behavior of the TEXTAREA input control, it has three possible values. NO_WRAP for no wrapping, SOFT_WRAP for simple wrapping with no newlines, and HARD_WRAP for simple wrapping with newlines.
More information about the usage and special tricks of the htmllib can be found inside of the library's documentation. And as always the DMCGI Guild is always happy to answer questions and help you out.