add docs and refactor GFStyle

This commit is contained in:
2024-06-18 18:30:16 -05:00
parent 1dc93d69f4
commit 5f4358277e
20 changed files with 579 additions and 282 deletions
+18 -9
View File
@@ -28,7 +28,7 @@ impl<FD: FormToolData> FormValidator<FD> {
}
}
/// A constructed form object.
/// A constructed, rendered form object.
///
/// With this, you can render the form, get the form data, or get
/// a validator for the data.
@@ -48,7 +48,7 @@ impl<FD: FormToolData> Form<FD> {
}
}
/// Validates the [`FormToolData`], returning the result
/// Validates the [`FormToolData`], returning the result.
pub fn validate(&self) -> Result<(), String> {
let validator = self.validator();
validator.validate(&self.fd.get_untracked())
@@ -79,13 +79,21 @@ impl<FD: FormToolData> IntoView for Form<FD> {
/// A trait allowing a form to be built around its containing data.
///
/// This trait defines a function that can be used to build all the data needed
/// to physically lay out a form, and how that data should be parsed and validated.
/// This trait defines a function that can be used to build all the data
/// needed to physically lay out a form, and how that data should be parsed
/// and validated.
pub trait FormToolData: Clone + 'static {
/// The style that this form uses.
type Style: FormStyle;
/// The context that this form is rendered in.
///
/// This will need to be provided when building a form or a validator.
/// Therefore, you will need to be able to replicate this context
/// on the client for rendering and the server for validating.
type Context: 'static;
/// Defines how the form should be layed out and how the data should be parsed and validated.
/// Defines how the form should be laid out and how the data should be
/// parsed and validated.
///
/// To construct a [`From`] object, use one of the `get_form` methods.
///
@@ -100,12 +108,13 @@ pub trait FormToolData: Clone + 'static {
/// [`ActionForm`](leptos_router::ActionForm) that sends the form data
/// directly by calling the server function.
///
/// By doing this, we avoid doing the [`FromFormData`](leptos_router::FromFormData)
/// By doing this, we avoid doing the
/// [`FromFormData`](leptos_router::FromFormData)
/// conversion. However, to support
/// [Progressive Enhancement](https://book.leptos.dev/progressive_enhancement/index.html),
/// you should name the form elements to work with a plain ActionForm anyway.
/// If progresssive enhancement is not important to you, you may freely
/// use this version
/// you should name the form elements to work with a plain ActionForm
/// anyway. If progresssive enhancement is not important to you, you may
/// freely use this version.
///
/// For the other ways to construct a [`Form`], see:
/// - [`get_action_form`](Self::get_action_form)