Malloy
Loading...
Searching...
No Matches
lib
malloy
core
html
form_field.hpp
1
#pragma once
2
3
#include <string>
4
5
namespace
malloy::html
6
{
10
struct
form_field_data
11
{
12
std::string name;
13
14
std::string
dispositions
;
15
std::string filename;
16
std::string type;
17
std::string content;
18
19
[[nodiscard]]
20
bool
21
has_data()
const
22
{
23
return
!content.empty();
24
}
25
};
26
30
struct
form_field
31
{
32
std::string name;
33
std::string
type
;
34
std::string
value
;
35
std::string
placeholder
;
36
std::string
label
;
37
bool
required
=
false
;
38
45
void
46
populate
(
const
form_field_data
& data)
47
{
48
if
(data.type ==
"password"
|| data.type ==
"file"
)
49
return
;
50
51
value
= data.content;
52
}
53
59
[[nodiscard]]
60
std::string
61
html_id
()
const
62
{
63
return
"form-field-"
+ name;
64
}
65
};
66
67
}
malloy::html
Definition:
form.hpp:12
malloy::html::form_field_data
Definition:
form_field.hpp:11
malloy::html::form_field_data::dispositions
std::string dispositions
The field name.
Definition:
form_field.hpp:14
malloy::html::form_field
Definition:
form_field.hpp:31
malloy::html::form_field::required
bool required
The label content.
Definition:
form_field.hpp:37
malloy::html::form_field::html_id
std::string html_id() const
Definition:
form_field.hpp:61
malloy::html::form_field::populate
void populate(const form_field_data &data)
Whether a value is required.
Definition:
form_field.hpp:46
malloy::html::form_field::type
std::string type
The field name.
Definition:
form_field.hpp:33
malloy::html::form_field::placeholder
std::string placeholder
The value of the field (for rendering only).
Definition:
form_field.hpp:35
malloy::html::form_field::label
std::string label
The placeholder.
Definition:
form_field.hpp:36
malloy::html::form_field::value
std::string value
The HTML type (eg. 'text', 'file', ...).
Definition:
form_field.hpp:34
Generated by
1.9.6