package mechaml

  1. Overview
  2. Docs

Operations on forms and inputs

type t

Phantom types for inputs

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

A form input

val name : t -> string option

Return the name of the form

val action : t -> Uri.t

Return the action attribute of the form

val uri : t -> Uri.t

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

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

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

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

Convert a form to a Soup node

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

Convert an input to a Soup node

Set directly the value(s) of a field

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

Get the value(s) of a field

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

Remove the value of a field

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

Return all set values as an associative list

val 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.
val checkbox_with : string -> t -> checkbox input option
val checkboxes : t -> checkbox input seq
val checkboxes_with : string -> t -> checkbox input seq
val radio_button_with : string -> t -> radio_button input option
val radio_buttons : t -> radio_button input seq
val radio_buttons_with : string -> t -> radio_button input seq
val select_list_with : string -> t -> select_list input option
val select_lists : t -> select_list input seq
val select_lists_with : string -> t -> select_list input seq
val field_with : string -> t -> field input option

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

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

Select numeric fields, either number or range

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

Reset or clear all the fields

val reset_all : t -> t
val clear_all : t -> t
module Checkbox : sig ... end

Operation on Checkboxes

module RadioButton : sig ... end

Operations on Radio Buttons

module SelectList : sig ... end

Operations on Menus (select lists)

module Field : sig ... end

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