Class InputModelBuilder<T, TProp>
- Namespace
- Htmx.Components.Models.Builders
- Assembly
- Htmx.Components.dll
Builder for creating strongly-typed input models for specific properties. Provides fluent configuration for form input controls with type safety and property binding.
public class InputModelBuilder<T, TProp> : BuilderBase<InputModelBuilder<T, TProp>, InputModel<T, TProp>>, IInputModelBuilder where T : class
Type Parameters
T
The model type that contains the property
TProp
The type of the property being configured
- Inheritance
-
InputModelBuilder<T, TProp>
- Implements
- Inherited Members
- Extension Methods
Methods
BuildImpl()
Builds the final InputModel instance with all configured properties. This method is called internally to create the final result.
protected override Task<InputModel<T, TProp>> BuildImpl()
Returns
- Task<InputModel<T, TProp>>
A task that represents the asynchronous build operation, containing the built InputModel
WithAttribute(string, string)
Adds a custom HTML attribute to the input control. Useful for data attributes, accessibility properties, or custom behavior.
public InputModelBuilder<T, TProp> WithAttribute(string key, string value)
Parameters
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithCssClass(string)
Sets CSS classes to apply to the input control. Used for styling and layout customization.
public InputModelBuilder<T, TProp> WithCssClass(string cssClass)
Parameters
cssClass
stringThe CSS class names to apply
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithKind(InputKind)
Sets the input kind (type) for the input control. Determines how the input will be rendered (text, number, select, etc.).
public InputModelBuilder<T, TProp> WithKind(InputKind kind)
Parameters
kind
InputKindThe input kind to use for rendering
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithLabel(string)
Sets the display label for the input control. Overrides the default label derived from the property name.
public InputModelBuilder<T, TProp> WithLabel(string label)
Parameters
label
stringThe label text to display
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithName(string)
Sets the name attribute for the input control. Overrides the default name derived from the property name.
public InputModelBuilder<T, TProp> WithName(string name)
Parameters
name
stringThe name to use for the input control
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithOptions(IEnumerable<KeyValuePair<string, string>>)
Sets the options for selection-based input controls (select, radio, checkbox). Each key-value pair represents an option where the key is the value and value is the display text.
public InputModelBuilder<T, TProp> WithOptions(IEnumerable<KeyValuePair<string, string>> options)
Parameters
options
IEnumerable<KeyValuePair<string, string>>The collection of options to use
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithPlaceholder(string)
Sets the placeholder text for the input control. Provides guidance to users about expected input.
public InputModelBuilder<T, TProp> WithPlaceholder(string placeholder)
Parameters
placeholder
stringThe placeholder text to display
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining
WithValue(TProp)
Sets the initial value for the input control. Provides a default or pre-populated value.
public InputModelBuilder<T, TProp> WithValue(TProp value)
Parameters
value
TPropThe initial value to set
Returns
- InputModelBuilder<T, TProp>
The current builder instance for method chaining