Replace the input! macro with an Input builder (#646)
* Replace the input! macro with an Input builder * Use a BTreeMap instead of an HashMap Followinf @fdb-hiroshima's advice * Rename Input::to_html to Input::html To make clippy happy * Wrap error messages in red paragraphs
This commit is contained in:
@@ -144,7 +144,11 @@
|
||||
|
||||
@if ctx.2.is_some() {
|
||||
<form method="post" action="@uri!(comments::create: blog_name = &blog.fqn, slug = &article.slug)">
|
||||
@input!(ctx.1, warning (optional text), "Content warning", comment_form, comment_errors, "")
|
||||
@(Input::new("warning", i18n!(ctx.1, "Content warning"))
|
||||
.default(&comment_form.warning)
|
||||
.error(&comment_errors)
|
||||
.optional()
|
||||
.html(ctx.1))
|
||||
|
||||
<label for="plume-editor">@i18n!(ctx.1, "Your comment")</label>
|
||||
@if let Some(ref prev) = previous_comment {
|
||||
|
||||
@@ -25,8 +25,15 @@
|
||||
} else {
|
||||
<form id="plume-fallback-editor" class="new-post" method="post" action="@uri!(posts::new: blog = blog.actor_id)" content-size="@content_len">
|
||||
}
|
||||
@input!(ctx.1, title (text), "Title", form, errors.clone(), "required")
|
||||
@input!(ctx.1, subtitle (optional text), "Subtitle", form, errors.clone(), "")
|
||||
@(Input::new("title", i18n!(ctx.1, "Title"))
|
||||
.default(&form.title)
|
||||
.error(&errors)
|
||||
.html(ctx.1))
|
||||
@(Input::new("subtitle", i18n!(ctx.1, "Subtitle"))
|
||||
.default(&form.subtitle)
|
||||
.error(&errors)
|
||||
.optional()
|
||||
.html(ctx.1))
|
||||
|
||||
@if let Some(ValidationErrorsKind::Field(errs)) = errors.clone().errors().get("content") {
|
||||
@format!(r#"<p class="error">{}</p>"#, errs[0].message.clone().unwrap_or_else(|| Cow::from("Unknown error")))
|
||||
@@ -40,9 +47,17 @@
|
||||
<a href="@uri!(medias::new)">@i18n!(ctx.1, "Upload media")</a>
|
||||
</p>
|
||||
|
||||
@input!(ctx.1, tags (optional text), "Tags, separated by commas", form, errors.clone(), "")
|
||||
|
||||
@input!(ctx.1, license (optional text), "License", "Leave it empty to reserve all rights", form, errors, "")
|
||||
@(Input::new("tags", i18n!(ctx.1, "Tags, separated by commas"))
|
||||
.default(&form.tags)
|
||||
.error(&errors)
|
||||
.optional()
|
||||
.html(ctx.1))
|
||||
@(Input::new("license", i18n!(ctx.1, "License"))
|
||||
.default(&form.license)
|
||||
.error(&errors)
|
||||
.optional()
|
||||
.details("Leave it empty to reserve all rights")
|
||||
.html(ctx.1))
|
||||
|
||||
@:image_select(ctx, "cover", i18n!(ctx.1, "Illustration"), true, medias, form.cover)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user