package mechaml

  1. Overview
  2. Docs

Module Page.FormSource

Operations on forms and inputs

Sourcetype t

Phantom types for inputs

Sourcetype checkbox
Sourcetype radio_button
Sourcetype select_list
Sourcetype menu
Sourcetype field
Sourcetype 'a input

A form input

Sourceval name : t -> string option

Return the name of the form

Sourceval action : t -> Uri.t

Return the action attribute of the form

Sourceval uri : t -> Uri.t

Return the absolute (resolved) uri corresponding to the action attribute

Sourceval meth : t -> [ `POST | `GET ]

Return the method attribute of the form or `GET if none

Sourceval to_node : t -> Soup.element Soup.node

Convert a form to a Soup node

Sourceval input_to_node : _ input -> Soup.element Soup.node

Convert an input to a Soup node

Set directly the value(s) of a field

Sourceval set : string -> string -> t -> t
Sourceval set_multi : string -> string list -> t -> t

Get the value(s) of a field

Sourceval get : string -> t -> string option
Sourceval get_multi : string -> t -> string list
Sourceval clear : string -> t -> t

Remove the value of a field

Sourceval values : t -> (string * string list) list

Return all set values as a list

Sourceval iname : _ input -> string option

Return the name of an input

All the following function are built using the same pattern.

  • xxxs (eg checkboxes) return all the inputs of a certain type as a lazy sequence. For example, checkboxes myform will return all the checkboxes of the form
  • xxx_with take a CSS selector as parameter, and return the first input that matches the selector, or None if there isn't any. Eg, fields_with myform "[name$=text2]" will try to find any text field which name ends with text2
  • xxxs_with proceed as the previous one, but return a lazy sequence of all inputs matching the selector.
Sourceval checkbox_with : string -> t -> checkbox input option
Sourceval checkboxes : t -> checkbox input seq
Sourceval checkboxes_with : string -> t -> checkbox input seq
Sourceval radio_button_with : string -> t -> radio_button input option
Sourceval radio_buttons : t -> radio_button input seq
Sourceval radio_buttons_with : string -> t -> radio_button input seq
Sourceval select_list_with : string -> t -> select_list input option
Sourceval select_lists : t -> select_list input seq
Sourceval select_lists_with : string -> t -> select_list input seq
Sourceval field_with : string -> t -> field input option

Select textual fields, either text, password, search, or textarea

Sourceval fields : t -> field input seq
Sourceval fields_with : string -> t -> field input seq
Sourceval numeric_with : string -> t -> field input option

Select numeric fields, either number or range

Sourceval numerics : t -> field input seq
Sourceval numerics_with : string -> t -> field input seq
Sourceval text_with : string -> t -> field input option
Sourceval texts : t -> field input seq
Sourceval texts_with : string -> t -> field input seq
Sourceval password_with : string -> t -> field input option
Sourceval passwords : t -> field input seq
Sourceval passwords_with : string -> t -> field input seq
Sourceval hidden_with : string -> t -> field input option
Sourceval hiddens : t -> field input seq
Sourceval hiddens_with : string -> t -> field input seq
Sourceval textarea_with : string -> t -> field input option
Sourceval textareas : t -> field input seq
Sourceval textareas_with : string -> t -> field input seq
Sourceval color_with : string -> t -> field input option
Sourceval colors : t -> field input seq
Sourceval colors_with : string -> t -> field input seq
Sourceval date_with : string -> t -> field input option
Sourceval dates : t -> field input seq
Sourceval dates_with : string -> t -> field input seq
Sourceval email_with : string -> t -> field input option
Sourceval emails : t -> field input seq
Sourceval emails_with : string -> t -> field input seq
Sourceval month_with : string -> t -> field input option
Sourceval months : t -> field input seq
Sourceval months_with : string -> t -> field input seq
Sourceval number_with : string -> t -> field input option
Sourceval numbers : t -> field input seq
Sourceval numbers_with : string -> t -> field input seq
Sourceval tel_with : string -> t -> field input option
Sourceval tels : t -> field input seq
Sourceval tels_with : string -> t -> field input seq
Sourceval search_with : string -> t -> field input option
Sourceval searchs : t -> field input seq
Sourceval searchs_with : string -> t -> field input seq
Sourceval time_with : string -> t -> field input option
Sourceval times : t -> field input seq
Sourceval times_with : string -> t -> field input seq
Sourceval url_with : string -> t -> field input option
Sourceval urls : t -> field input seq
Sourceval urls_with : string -> t -> field input seq

Reset or clear all the fields

Sourceval reset_all : t -> t
Sourceval clear_all : t -> t
Sourcemodule Checkbox : sig ... end

Operation on Checkboxes

Sourcemodule RadioButton : sig ... end

Operations on Radio Buttons

Sourcemodule SelectList : sig ... end

Operations on Menu (select lists)

Sourcemodule Field : sig ... end

Operations on general fields : textarea, text, password, color, date, etc.