Yew Form
Bringing MVC to Yew! A set of Yew component to map and validate a model to a HTML form.
Early Work in Progress
Supports:
- 2-way Binding to struct (with support for nested structs)
- Validation (using Keats Validator)
Example
Consider the following model:
The struct can be bound to a Yew form using the following definition:
For now, the Form needs to be instantiated as follows:
Fields can then be added to the form as follows:
form=&self.form field_name="first_name" oninput=self.link.callback(|_: InputData| AppMessage::Update) />
...
form=&self.form field_name="address.street" oninput=self.link.callback(|_: InputData| AppMessage::Update) />
The Field component takes care of two way binding between struct Registration and the HTML <input>
Validation is done automatically when the user edits the form or programmatically.
if self.form.validate
Todo/Wish List:
- Remove clone requirement from model
- Add
derivefor model to remove need forvec!of fields - Make
oninputoptional - Make Yew update the view when
Fieldis updated - Need to add additional HTML attribute to
Field - Remove hard-coded Bootstrap styles
- Add support for additional types
Change Log
0.1.2
- Added CheckBox
0.1.1
- Make
Field::oninputoptional