#[derive(Default)]
pub struct FieldRadio {
field: Field,
+ inline: bool,
options: Vec<FOption>,
}
context.insert("help", &self.field.help);
context.insert("class", &self.field.class);
context.insert("value", &self.field.value);
+ context.insert("inline", &self.inline);
context.insert("options", &self.options);
s.push_str(self.field.tmpl.render("field", &context).unwrap().as_str());
match f.field.tmpl.add_raw_template("field", r#"{% if label %}<div class="mb-3">
<label for="{{ name }}" class="form-label">{{ label }}</label><br/>{% endif %}
{% for o in options %}
- <div class="form-check{% if help %} is-invalid{% endif %}">
+ <div class="form-check{% if inline %} form-check-inline{% endif %}{% if help %} is-invalid{% endif %}">
<input type="radio" class="form-check-input{% if help %} is-invalid{% endif %}{% if class %} {{ class }}{% endif %}" name="{{ name }}" id="{{ name }}_{{ loop.index }}" value="{{ o.value }}"{% if value == o.value %} checked{% endif %}/>
<label class="form-label" for="{{ name }}_{{ loop.index }}">{{ o.label }}</label>
</div>
};
match f.field.tmpl.add_raw_template("field_single", r#"<div class="form-check{% if help %} is-invalid{% endif %}">
- <input type="radio" class="form-check-input{% if help %} is-invalid{% endif %}{% if class %} {{ class }}{% endif %}" name="{{ name }}" id="{{ name }}_{{ idx }}" value="{{ value }}"{% if checked != "" %} checked{% endif %}/>
+ <input type="radio" class="form-check-input{% if inline %} form-check-inline{% endif %}{% if help %} is-invalid{% endif %}{% if class %} {{ class }}{% endif %}" name="{{ name }}" id="{{ name }}_{{ idx }}" value="{{ value }}"{% if checked != "" %} checked{% endif %}/>
<label class="form-label" for="{{ name }}_{{ idx }}">{{ label }}</label>
</div>"#) {
Err(e) => { println!("{:?}", e) },
f
}
+ pub fn get_inline(&self) -> bool {
+ self.inline
+ }
+
+ pub fn set_inline(&mut self, inline: bool) {
+ self.inline = inline;
+ }
+
pub fn add_option(&mut self, option: FOption) {
self.options.push(option);
}