generated from mitchell/rust_template
minor tweaks
This commit is contained in:
parent
bc1216ef26
commit
9a27f3c917
@ -4,5 +4,6 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = "0.6.9"
|
leptos = "0.6"
|
||||||
|
leptos_router = "0.6"
|
||||||
|
|
||||||
|
|||||||
@ -299,14 +299,16 @@ pub trait FormData: Default + Clone + 'static {
|
|||||||
|
|
||||||
/// Defines how the form should be layed out and how the data should be parsed and validated.
|
/// Defines how the form should be layed out and how the data should be parsed and validated.
|
||||||
///
|
///
|
||||||
|
/// To construct a [`From`] object, use one of the [`get_form`()] methods.
|
||||||
|
///
|
||||||
/// Uses the given form builder to specify what fields should be present
|
/// Uses the given form builder to specify what fields should be present
|
||||||
/// in the form, what properties those fields should have, and how that
|
/// in the form, what properties those fields should have, and how that
|
||||||
/// data should be parsed and checked.
|
/// data should be parsed and checked.
|
||||||
fn build_form(fb: FormBuilder<Self, Self::Style>) -> FormBuilder<Self, Self::Style>;
|
fn build_form(fb: FormBuilder<Self, Self::Style>) -> FormBuilder<Self, Self::Style>;
|
||||||
|
|
||||||
/// Gets the [`Form`] for this FormData type.
|
/// Constructs a [`Form`] for this FormData type.
|
||||||
///
|
///
|
||||||
/// The [`Form`] provides the way to render the form
|
/// The [`Form`] provides the way to render the form.
|
||||||
fn get_form(style: Self::Style) -> Form<Self> {
|
fn get_form(style: Self::Style) -> Form<Self> {
|
||||||
let builder = FormBuilder::new_full_builder(style);
|
let builder = FormBuilder::new_full_builder(style);
|
||||||
let builder = Self::build_form(builder);
|
let builder = Self::build_form(builder);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ use crate::controls::{
|
|||||||
text_input::TextInputData, ControlData, ControlRenderData,
|
text_input::TextInputData, ControlData, ControlRenderData,
|
||||||
};
|
};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
|
use leptos_router::Form;
|
||||||
|
|
||||||
pub enum TailwindGridStylingAttributes {
|
pub enum TailwindGridStylingAttributes {
|
||||||
Width(u32),
|
Width(u32),
|
||||||
@ -18,9 +19,9 @@ impl FormStyle for TailwindGridFormStyle {
|
|||||||
// TODO: something about an on-submit thing
|
// TODO: something about an on-submit thing
|
||||||
fn form_frame(&self, children: View) -> View {
|
fn form_frame(&self, children: View) -> View {
|
||||||
view! {
|
view! {
|
||||||
<form>
|
<Form action="">
|
||||||
{children}
|
{children}
|
||||||
</form>
|
</Form>
|
||||||
}
|
}
|
||||||
.into_view()
|
.into_view()
|
||||||
}
|
}
|
||||||
@ -43,13 +44,17 @@ impl FormStyle for TailwindGridFormStyle {
|
|||||||
) -> View {
|
) -> View {
|
||||||
view! {
|
view! {
|
||||||
<div>
|
<div>
|
||||||
{move || format!("{:?}", validation_state.get())}
|
<div>
|
||||||
<label
|
<label
|
||||||
for={&control.data.name}
|
for={&control.data.name}
|
||||||
class="block uppercase tracking-wide text-left text-gray-700 text-md font-bold ml-2 mb-1"
|
class="block uppercase tracking-wide text-left text-gray-700 text-md font-bold ml-2 mb-1 inline"
|
||||||
>
|
>
|
||||||
{control.data.label.as_ref()}
|
{control.data.label.as_ref()}
|
||||||
</label>
|
</label>
|
||||||
|
<span class="inline pl-2 text-red-600">
|
||||||
|
{move || format!("{}", validation_state.get().err().unwrap_or_default())}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<input
|
<input
|
||||||
// TODO:
|
// TODO:
|
||||||
type=control.data.input_type
|
type=control.data.input_type
|
||||||
|
|||||||
Reference in New Issue
Block a user