forms are cleaner and more comfy to use now uwu
This commit is contained in:
parent
cb2c7af03d
commit
30f08491be
5 changed files with 42 additions and 7 deletions
|
@ -137,6 +137,12 @@ div.form-error {
|
|||
margin-top: .5em;
|
||||
}
|
||||
|
||||
p.field-error {
|
||||
margin: .2em 0 0 0;
|
||||
font-size: .8em;
|
||||
color: var(--clr-error-primary-40);
|
||||
}
|
||||
|
||||
.split {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
|
|
@ -83,10 +83,7 @@ fn validate_chassis<'v>(a: &str, b: &str, c: &str, field: &str) -> form::Result<
|
|||
&& c.len() <= 256;
|
||||
|
||||
if !all_empty && !all_full {
|
||||
Err(form::Error::validation(format!(
|
||||
"missing chassis field {}",
|
||||
field
|
||||
)))?;
|
||||
Err(form::Error::validation(format!("missing {}", field)))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -3,4 +3,18 @@
|
|||
{% if values | length > 0 %}
|
||||
value="{{values | first}}"
|
||||
{% endif %}
|
||||
{% endmacro value %}
|
||||
{% endmacro value %}
|
||||
|
||||
{% macro textarea(ctx, name) %}
|
||||
{%- set values = ctx.values | get(key=name, default=[]) -%}
|
||||
{%- if values | length > 0 -%}
|
||||
{{- values|first -}}
|
||||
{%- endif -%}
|
||||
{% endmacro value %}
|
||||
|
||||
{% macro error(ctx, name) %}
|
||||
{% set errors = ctx.errors | get(key=name, default=[]) %}
|
||||
{% if errors | length > 0 %}
|
||||
<p class="field-error">{{errors | first | get(key="msg") }}</p>
|
||||
{% endif %}
|
||||
{% endmacro error %}
|
|
@ -42,6 +42,9 @@
|
|||
<p class="heading"><label for="ident">Enter its ID</label></p>
|
||||
<input type="text" inputmode="numeric" pattern="\d{6}" id="ident" name="ident" required size="6"
|
||||
placeholder="000000" {{form::value(ctx=previous, name="ident" )}} />
|
||||
{{form::error(ctx=previous, name="ident")}}
|
||||
|
||||
|
||||
<p>Or pick one of those pre-generated ones</p>
|
||||
|
||||
<div id="pregen_ids">
|
||||
|
@ -55,6 +58,7 @@
|
|||
ID</label></p>
|
||||
<input type="text" pattern="(0x)?[a-fA-F0-9]+" id="microchip_id" name="microchip_id"
|
||||
placeholder="A hexadecimal ID" {{form::value(ctx=previous, name="microchip_id" )}}>
|
||||
{{form::error(ctx=previous, name="microchip_id")}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -69,6 +73,7 @@
|
|||
<div>
|
||||
<input type="text" name="name" id="name" required placeholder="A name or callsign"
|
||||
{{form::value(ctx=previous, name="name" )}} />
|
||||
{{form::error(ctx=previous, name="name")}}
|
||||
<p class="note">Remember: names only mean what you want them to!</p>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -78,6 +83,9 @@
|
|||
placeholder="them" {{form::value(ctx=previous, name="pronoun_object" )}} /> /
|
||||
<input class="pronoun" type="text" name="pronoun_possessive" required maxlength="255"
|
||||
placeholder="theirs" {{form::value(ctx=previous, name="pronoun_possessive" )}} />
|
||||
{{form::error(ctx=previous, name="pronoun_subject")}}
|
||||
{{form::error(ctx=previous, name="pronoun_object")}}
|
||||
{{form::error(ctx=previous, name="pronoun_possessive")}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -88,11 +96,13 @@
|
|||
<input type="text" name="handler_name" id="handler_name"
|
||||
placeholder="Another name or callsign" {{form::value(ctx=previous, name="handler_name"
|
||||
)}} />
|
||||
{{form::error(ctx=previous, name="handler_name")}}
|
||||
</div>
|
||||
<div>
|
||||
<input type="url" name="handler_link" id="handler_link"
|
||||
placeholder="E-mails can be entered using mailto:" {{form::value(ctx=previous,
|
||||
name="handler_link" )}} />
|
||||
{{form::error(ctx=previous, name="handler_link")}}
|
||||
<p class="note">Optional, will make the handler's name clickable.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -114,23 +124,26 @@
|
|||
<label for="kind">What kind of entity?</label>
|
||||
<input type="text" name="kind" id="kind" placeholder="Something" {{form::value(ctx=previous,
|
||||
name="kind" )}} />
|
||||
{{form::error(ctx=previous, name="kind")}}
|
||||
</div>
|
||||
<div>
|
||||
<label for="breed">What breed is it?</label>
|
||||
<input type="text" name="breed" id="breed" placeholder="Mutt :3" {{form::value(ctx=previous,
|
||||
name="breed" )}} />
|
||||
{{form::error(ctx=previous, name="breed")}}
|
||||
</div>
|
||||
<div>
|
||||
<label for="behaviour">Its general behaviour</label>
|
||||
<input type="text" name="behaviour" id="behaviour" placeholder="Totally independent"
|
||||
{{form::value(ctx=previous, name="behaviour" )}} />
|
||||
{{form::error(ctx=previous, name="behaviour")}}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="description">A description about it?</label>
|
||||
<textarea name="description" id="description" rows="10"
|
||||
placeholder="feel free to write a bit about it or not at all" {{form::value(ctx=previous,
|
||||
name="description" )}}></textarea>
|
||||
placeholder="feel free to write a bit about it or not at all">{{form::textarea(ctx=previous, name="description")}}</textarea>
|
||||
{{form::error(ctx=previous, name="description")}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -161,6 +174,11 @@
|
|||
{{form::value(ctx=previous, name="chassis_color" )}} />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{{form::error(ctx=previous, name="chassis_type")}}
|
||||
{{form::error(ctx=previous, name="chassis_id")}}
|
||||
{{form::error(ctx=previous, name="chassis_color")}}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue