Generic Options
In Erlang Web framework all embedded basic types support some common set of the features (parameters). Moreover, almost each basic type adds some new ones: for validating, formatting or other.
Record definition parameters
parameter |
format |
description |
description |
"Description" or {key, Key} |
Specifies the text that should be displayed as a field description during the form generation. The provided description could be either a string (and it will be rendered as it is) or a tuple: {key, Key} for internationalization: the Key must be in the format accepted by e_lang module. By default it is a field long name. |
private |
true or false |
If set to true - the selected field will not be displayed on the form. By default set to false. |
optional |
Default |
If the optional clause is provided and there is no data entered for the field, the Default value will be used. |
html_attrs |
[{Attr1, Val1}, {Attr2, Val2}, ...] |
Specifies the list of the HTML attributes that will be added to the rendered tag. The attributes must be either atoms or lists, the values could be atoms, lists or integers. |
Validation
parameter |
format |
description |
unique |
atom() |
Checks if the attribute is unique within its domain, that is within a table the record entries are held. This option may be useful when one wants to inserts only the unique data into the database, e.g. do not allow two users to use the same e-mail address. |
Examples
HTML attributes adding
The following entry in the record definition:
{string, [{html_attrs, [{size, 20},
{class, string_input},
{alt, "Your name"}]}
]},will generate the following HTML code:
<input type="string" size="20" class="string_input" alt="Your name" />
Moreover, adding the standard HTML attributes inside the wpart tags will move them to the corresponding HTML tags. For example, the following tag placed in the template file:
<wpart:text name="blog_entry" cols="300" rows="50" />
will be expanded to:
<textarea name="blog_entry" cols="300" rows="50"> </textarea>
