1 #ifndef EL__DOCUMENT_FORMS_H
2 #define EL__DOCUMENT_FORMS_H
4 #include "util/lists.h"
15 FORM_METHOD_POST_TEXT_PLAIN
,
19 LIST_HEAD(struct form
);
21 /** The value of @c form_num serves both as a unique ID of the form.
22 * However @c form_num and #form_end also stores information about where
23 * in the source the form is positioned. Combined they are used to
24 * figured which form items belong to which forms after rendering
27 * Initially the range between @c form_num and #form_end will
28 * stretch from 0 to INT_MAX. When a new form is added the
29 * range is partitioned so the forms each has unique source
32 int form_end
; /**< @see #form_num */
34 unsigned char *action
;
36 unsigned char *onsubmit
;
37 unsigned char *target
;
38 enum form_method method
;
40 LIST_OF(struct form_control
) items
;
66 #define form_field_is_readonly(field) ((field)->mode != FORM_MODE_NORMAL)
75 LIST_HEAD(struct form_control
);
80 /** The value of @c position is relative to the place of the
81 * form item in the source. */
87 unsigned char *id
; /**< used by scripts */
90 /** Default value, cannot be changed by document scripts.
91 * - For ::FC_TEXT, ::FC_PASSWORD, and ::FC_TEXTAREA:
92 * @c default_value is in the charset of the document.
93 * - For ::FC_FILE: The parser does not set @c default_value. */
94 unsigned char *default_value
;
101 unsigned char **values
;
102 /** Labels in a selection menu.
103 * - For ::FC_SELECT: @c labels are in the charset of the terminal.
104 * (That charset can be UTF-8 only if CONFIG_UTF8 is defined,
105 * and is assumed to be unibyte otherwise.) The charset of
106 * the document and the UTF-8 I/O option have no effect here. */
107 unsigned char **labels
;
108 struct menu_item
*menu
;
111 /* Numerical form type <-> form type name */
112 int str2form_type(unsigned char *s
);
113 unsigned char *form_type2str(enum form_type num
);
115 struct form
*init_form(void);
116 void done_form(struct form
*form
);
117 int has_form_submit(struct form
*form
);
119 int get_form_control_link(struct document
*document
, struct form_control
*fc
);
120 void done_form_control(struct form_control
*fc
);