@@ -27,11 +27,17 @@ Experience FormCraft in action! Visit our [interactive demo](https://phmatray.gi
2727- 📤 File upload capabilities
2828- 🎨 Real-time form generation
2929
30- ## 🎉 What's New in v2.0 .0
30+ ## 🎉 What's New in v2.5 .0
3131
32- FormCraft v2.0 .0 brings exciting new features and improvements :
32+ FormCraft v2.5 .0 introduces powerful attribute-based form generation and more :
3333
34- ### 🔒 Security Features
34+ ### 🏷️ Attribute-Based Form Generation (NEW!)
35+ - ** Zero-configuration forms** - Generate complete forms from model attributes
36+ - ** Rich attribute library** - TextField, EmailField, NumberField, DateField, SelectField, CheckboxField, TextArea
37+ - ** Automatic validation** - Integrates with DataAnnotations attributes
38+ - ** One-line setup** - Just call ` .AddFieldsFromAttributes() `
39+
40+ ### 🔒 Security Features (v2.0.0)
3541- ** Field-level encryption** for sensitive data protection
3642- ** CSRF protection** with built-in anti-forgery tokens
3743- ** Rate limiting** to prevent form spam
@@ -46,7 +52,7 @@ FormCraft v2.0.0 brings exciting new features and improvements:
4652- ** Enhanced performance** with optimized rendering
4753- ** Better type safety** with improved generic constraints
4854- ** Comprehensive documentation** with live examples
49- - ** 500 + unit tests** ensuring reliability
55+ - ** 550 + unit tests** ensuring reliability
5056
5157## 🚀 Why FormCraft?
5258
@@ -56,13 +62,14 @@ FormCraft revolutionizes form building in Blazor applications by providing a **f
5662
5763- 🔒 ** Type-Safe** - Full IntelliSense support with compile-time validation
5864- 🎯 ** Fluent API** - Intuitive method chaining for readable form configuration
65+ - 🏷️ ** Attribute-Based Forms** - Generate forms from model attributes with zero configuration
5966- 🎨 ** MudBlazor Integration** - Beautiful Material Design components out of the box
6067- 🔄 ** Dynamic Forms** - Create forms that adapt based on user input
6168- ✅ ** Advanced Validation** - Built-in, custom, and async validators
6269- 🔗 ** Field Dependencies** - Link fields together with reactive updates
6370- 📐 ** Flexible Layouts** - Multiple layout options to fit your design
6471- 🚀 ** High Performance** - Optimized rendering with minimal overhead
65- - 🧪 ** Fully Tested** - 400 + unit tests ensuring reliability
72+ - 🧪 ** Fully Tested** - 550 + unit tests ensuring reliability
6673
6774## 📦 Installation
6875
@@ -149,22 +156,117 @@ public class UserRegistration
149156}
150157```
151158
152- Alternatively , you can configure fields directly on your model using attributes :
159+ ## 🏷️ Attribute-Based Forms (NEW!)
160+
161+ Define your forms directly on your model with attributes - no configuration code needed !
162+
163+ ### Define Your Model with Attributes
153164
154165```csharp
155- public class ContactModel
166+ public class UserRegistration
156167{
157- [Required ]
158168 [TextField (" First Name" , " Enter your first name" )]
169+ [Required (ErrorMessage = " First name is required" )]
159170 [MinLength (2 )]
160171 public string FirstName { get ; set ; } = string .Empty ;
172+
173+ [TextField (" Last Name" , " Enter your last name" )]
174+ [Required (ErrorMessage = " Last name is required" )]
175+ public string LastName { get ; set ; } = string .Empty ;
176+
177+ [EmailField (" Email Address" )]
178+ [Required ]
179+ public string Email { get ; set ; } = string .Empty ;
180+
181+ [NumberField (" Age" , " Your age" )]
182+ [Range (18 , 120 , ErrorMessage = " Age must be between 18 and 120" )]
183+ public int Age { get ; set ; }
184+
185+ [DateField (" Date of Birth" )]
186+ public DateTime BirthDate { get ; set ; }
187+
188+ [SelectField (" Country" , " United States" , " Canada" , " United Kingdom" , " Australia" )]
189+ public string Country { get ; set ; } = string .Empty ;
190+
191+ [TextArea (" Bio" , " Tell us about yourself" )]
192+ [MaxLength (500 )]
193+ public string Bio { get ; set ; } = string .Empty ;
194+
195+ [CheckboxField (" Newsletter" , " Subscribe to our newsletter" )]
196+ public bool SubscribeToNewsletter { get ; set ; }
161197}
198+ ```
199+
200+ ### Generate the Form with One Line
201+
202+ ```csharp
203+ var formConfig = FormBuilder <UserRegistration >.Create ()
204+ .AddFieldsFromAttributes () // That's it! 🎉
205+ .Build ();
206+ ```
162207
163- var config = FormBuilder <ContactModel >.Create ()
208+ ### Available Attribute Types
209+
210+ - ` [TextField] ` - Standard text input
211+ - ` [EmailField] ` - Email input with validation
212+ - ` [NumberField] ` - Numeric input with min/max support
213+ - ` [DateField] ` - Date picker with constraints
214+ - ` [SelectField] ` - Dropdown with predefined options
215+ - ` [CheckboxField] ` - Boolean checkbox
216+ - ` [TextArea] ` - Multiline text input
217+
218+ All attributes work seamlessly with standard DataAnnotations validators like ` [Required] ` , ` [MinLength] ` , ` [MaxLength] ` , ` [Range] ` , and more!
219+
220+ ### Comparison: Fluent API vs Attributes
221+
222+ <table >
223+ <tr >
224+ <th >Fluent API</th >
225+ <th >Attribute-Based</th >
226+ </tr >
227+ <tr >
228+ <td >
229+
230+ ``` csharp
231+ var config = FormBuilder <User >.Create ()
232+ .AddField (x => x .Name , field => field
233+ .WithLabel (" Full Name" )
234+ .WithPlaceholder (" Enter name" )
235+ .Required (" Name is required" )
236+ .WithMinLength (2 ))
237+ .AddField (x => x .Email , field => field
238+ .WithLabel (" Email" )
239+ .WithInputType (" email" )
240+ .Required ())
241+ .Build ();
242+ ```
243+
244+ </td >
245+ <td >
246+
247+ ``` csharp
248+ public class User
249+ {
250+ [TextField (" Full Name" , " Enter name" )]
251+ [Required (ErrorMessage = " Name is required" )]
252+ [MinLength (2 )]
253+ public string Name { get ; set ; }
254+
255+ [EmailField (" Email" )]
256+ [Required ]
257+ public string Email { get ; set ; }
258+ }
259+
260+ // One line to generate!
261+ var config = FormBuilder <User >.Create ()
164262 .AddFieldsFromAttributes ()
165263 .Build ();
166264```
167265
266+ </td >
267+ </tr >
268+ </table >
269+
168270## 🎨 Examples
169271
170272### Dynamic Field Dependencies
0 commit comments