Malloy
Loading...
Searching...
No Matches
form_field.hpp
1#pragma once
2
3#include <string>
4
5namespace malloy::html
6{
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
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
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}
Definition: form.hpp:12
Definition: form_field.hpp:11
std::string dispositions
The field name.
Definition: form_field.hpp:14
Definition: form_field.hpp:31
bool required
The label content.
Definition: form_field.hpp:37
std::string html_id() const
Definition: form_field.hpp:61
void populate(const form_field_data &data)
Whether a value is required.
Definition: form_field.hpp:46
std::string type
The field name.
Definition: form_field.hpp:33
std::string placeholder
The value of the field (for rendering only).
Definition: form_field.hpp:35
std::string label
The placeholder.
Definition: form_field.hpp:36
std::string value
The HTML type (eg. 'text', 'file', ...).
Definition: form_field.hpp:34