form generator
This commit is contained in:
parent
80ae1c4f91
commit
58bd5490e2
7 changed files with 593 additions and 2 deletions
|
|
@ -310,3 +310,258 @@ func TablerHome(c *core.Context) *core.Response {
|
|||
}
|
||||
return c.Response.Template("tabler_homepage.html", data)
|
||||
}
|
||||
|
||||
// DemoForm1 renders the sample contact form using the form generator.
|
||||
func DemoForm1(c *core.Context) *core.Response {
|
||||
type demoForm1Data struct {
|
||||
TablerPageData
|
||||
FormDefinition FormtablerFormDefinition
|
||||
}
|
||||
data := demoForm1Data{
|
||||
TablerPageData: TablerPageData{
|
||||
PageTitle: "Demo Form 1",
|
||||
PageDescription: "Sample contact form generated from JSON definition",
|
||||
ShowTopbar: true,
|
||||
Sidebar: false,
|
||||
PageHeader: "Contact Form",
|
||||
PagePretitle: "Demo Form Generator",
|
||||
UserName: "Jane Doe",
|
||||
UserRole: "Administrator",
|
||||
NavbarMenu: SampleNavbarMenu(),
|
||||
},
|
||||
FormDefinition: FormtablerFormDefinition{
|
||||
ID: "contact-form",
|
||||
Title: "Contact us",
|
||||
SuccessMessage: "Thanks! We'll get back to you soon.",
|
||||
Method: "POST",
|
||||
Fields: []FormtablerFormField{
|
||||
{
|
||||
Name: "name",
|
||||
Label: "Name",
|
||||
Type: "text",
|
||||
Required: true,
|
||||
Placeholder: "Jane Doe",
|
||||
},
|
||||
{
|
||||
Name: "email",
|
||||
Label: "Email",
|
||||
Type: "email",
|
||||
Required: true,
|
||||
Placeholder: "jane@example.com",
|
||||
},
|
||||
{
|
||||
Name: "phone",
|
||||
Label: "Phone",
|
||||
Type: "phone",
|
||||
Required: false,
|
||||
Placeholder: "+1 555 000 0000",
|
||||
},
|
||||
{
|
||||
Name: "message",
|
||||
Label: "Message",
|
||||
Type: "textarea",
|
||||
Required: true,
|
||||
Placeholder: "How can we help?",
|
||||
MaxLength: 1000,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
return c.Response.Template("apptabler_demoform.html", data)
|
||||
}
|
||||
|
||||
// DemoForm2 renders an advanced form using all available field types.
|
||||
func DemoForm2(c *core.Context) *core.Response {
|
||||
type demoForm2Data struct {
|
||||
TablerPageData
|
||||
FormDefinition FormtablerFormDefinition
|
||||
}
|
||||
data := demoForm2Data{
|
||||
TablerPageData: TablerPageData{
|
||||
PageTitle: "Demo Form 2",
|
||||
PageDescription: "Advanced form with all field types",
|
||||
ShowTopbar: true,
|
||||
Sidebar: false,
|
||||
PageHeader: "Advanced Registration Form",
|
||||
PagePretitle: "Demo Form Generator",
|
||||
UserName: "Jane Doe",
|
||||
UserRole: "Administrator",
|
||||
NavbarMenu: SampleNavbarMenu(),
|
||||
},
|
||||
FormDefinition: FormtablerFormDefinition{
|
||||
ID: "advanced-registration",
|
||||
Title: "User Registration",
|
||||
SuccessMessage: "Registration submitted successfully! We'll review your application.",
|
||||
Method: "POST",
|
||||
Columns: 3,
|
||||
FieldsetTitle: "Personal Information",
|
||||
FieldsetDescription: "Please fill in all required fields marked with an asterisk (*).",
|
||||
Fields: []FormtablerFormField{
|
||||
{
|
||||
Name: "first_name",
|
||||
Label: "First Name",
|
||||
Type: "text",
|
||||
Required: true,
|
||||
Placeholder: "John",
|
||||
MinLength: 2,
|
||||
MaxLength: 50,
|
||||
Autofocus: true,
|
||||
},
|
||||
{
|
||||
Name: "last_name",
|
||||
Label: "Last Name",
|
||||
Type: "text",
|
||||
Required: true,
|
||||
Placeholder: "Doe",
|
||||
MinLength: 2,
|
||||
MaxLength: 50,
|
||||
},
|
||||
{
|
||||
Name: "email",
|
||||
Label: "Email Address",
|
||||
Type: "email",
|
||||
Required: true,
|
||||
Placeholder: "john.doe@example.com",
|
||||
},
|
||||
{
|
||||
Name: "phone",
|
||||
Label: "Phone Number",
|
||||
Type: "phone",
|
||||
Required: true,
|
||||
Placeholder: "+1 (555) 000-0000",
|
||||
HelpText: "Include country code for international numbers.",
|
||||
},
|
||||
{
|
||||
Name: "account_type",
|
||||
Label: "Account Type",
|
||||
Type: "select",
|
||||
Required: true,
|
||||
Options: []FormtablerFormFieldOption{
|
||||
{Label: "Personal", Value: "personal", Selected: true},
|
||||
{Label: "Business", Value: "business"},
|
||||
{Label: "Enterprise", Value: "enterprise"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
Label: "Password",
|
||||
Type: "password",
|
||||
Required: true,
|
||||
Placeholder: "••••••••",
|
||||
MinLength: 8,
|
||||
MaxLength: 128,
|
||||
HelpText: "At least 8 characters with uppercase, lowercase and numbers.",
|
||||
},
|
||||
{
|
||||
Name: "company",
|
||||
Label: "Company Name",
|
||||
Type: "text",
|
||||
Placeholder: "Acme Inc.",
|
||||
HelpText: "Only required for Business and Enterprise accounts.",
|
||||
},
|
||||
{
|
||||
Name: "website",
|
||||
Label: "Website",
|
||||
Type: "url",
|
||||
Placeholder: "https://example.com",
|
||||
},
|
||||
{
|
||||
Name: "bio",
|
||||
Label: "Biography",
|
||||
Type: "textarea",
|
||||
Placeholder: "Tell us about yourself...",
|
||||
MaxLength: 500,
|
||||
HelpText: "Maximum 500 characters.",
|
||||
},
|
||||
{
|
||||
Name: "birth_date",
|
||||
Label: "Date of Birth",
|
||||
Type: "date",
|
||||
},
|
||||
{
|
||||
Name: "preferred_language",
|
||||
Label: "Preferred Language",
|
||||
Type: "select",
|
||||
Options: []FormtablerFormFieldOption{
|
||||
{Label: "English", Value: "en", Selected: true},
|
||||
{Label: "Spanish", Value: "es"},
|
||||
{Label: "French", Value: "fr"},
|
||||
{Label: "German", Value: "de"},
|
||||
{Label: "Japanese", Value: "ja"},
|
||||
{Label: "Chinese", Value: "zh"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "experience_level",
|
||||
Label: "Experience Level",
|
||||
Type: "radio",
|
||||
Required: true,
|
||||
Options: []FormtablerFormFieldOption{
|
||||
{Label: "Beginner", Value: "beginner", Checked: true},
|
||||
{Label: "Intermediate", Value: "intermediate"},
|
||||
{Label: "Advanced", Value: "advanced"},
|
||||
{Label: "Expert", Value: "expert"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "skills",
|
||||
Label: "Skills & Technologies",
|
||||
Type: "checkbox",
|
||||
HelpText: "Select all that apply.",
|
||||
Options: []FormtablerFormFieldOption{
|
||||
{Label: "Go", Value: "go", Checked: true},
|
||||
{Label: "JavaScript", Value: "javascript", Checked: true},
|
||||
{Label: "Python", Value: "python"},
|
||||
{Label: "Rust", Value: "rust"},
|
||||
{Label: "Docker", Value: "docker"},
|
||||
{Label: "Kubernetes", Value: "kubernetes"},
|
||||
{Label: "PostgreSQL", Value: "postgresql"},
|
||||
{Label: "Redis", Value: "redis"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "notifications",
|
||||
Label: "Email Notifications",
|
||||
Type: "toggle",
|
||||
HelpText: "Receive updates about new features and security alerts.",
|
||||
},
|
||||
{
|
||||
Name: "website_color",
|
||||
Label: "Preferred Accent Color",
|
||||
Type: "color",
|
||||
Value: "#206bc4",
|
||||
},
|
||||
{
|
||||
Name: "priority_level",
|
||||
Label: "Priority Level",
|
||||
Type: "range",
|
||||
Min: 1,
|
||||
Max: 10,
|
||||
Step: 1,
|
||||
Value: "5",
|
||||
HelpText: "1 = Lowest priority, 10 = Highest priority",
|
||||
},
|
||||
{
|
||||
Name: "agree_terms",
|
||||
Label: "I agree to the Terms of Service and Privacy Policy",
|
||||
Type: "checkbox",
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "marketing_consent",
|
||||
Label: "I would like to receive marketing communications",
|
||||
Type: "toggle",
|
||||
},
|
||||
{
|
||||
Name: "csrf_token",
|
||||
Type: "hidden",
|
||||
Value: "abc123xyz",
|
||||
},
|
||||
},
|
||||
SubmitText: "Create Account",
|
||||
ShowReset: true,
|
||||
ResetText: "Clear All",
|
||||
},
|
||||
}
|
||||
return c.Response.Template("apptabler_demoform.html", data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue