ok
9ad6d2382305f016242e9e2f13efa702f7e88295
7 files changed
WebFormBuilder/Controllers/SubmitValueController.csWebFormBuilder/Examples/form.jsonWebFormBuilder/Examples/formConfigData.jsonWebFormBuilder/Examples/text.jsonWebFormBuilder/Models/FormField.csWebFormBuilder/Program.csWebFormBuilder/wwwroot/WebForm.css
diff --git a/WebFormBuilder/Controllers/SubmitValueController.cs b/WebFormBuilder/Controllers/SubmitValueController.cs
index 857487f..5704ff6 100644
--- a/WebFormBuilder/Controllers/SubmitValueController.cs
+++ b/WebFormBuilder/Controllers/SubmitValueController.cs
@@ -18,7 +18,6 @@ public class SubmitValueController : ControllerBase
}
[HttpPost]
- //[Consumes("multipart/form-data")]
public IActionResult ChangeValue([FromBody] Input input)
{
Debug.WriteLine($"formname:{input.formname} name:{input.name} type:{input.type} val:{input.val} state:{input.state}");
diff --git a/WebFormBuilder/Examples/form.json b/WebFormBuilder/Examples/form.json
new file mode 100644
index 0000000..57e4b32
--- /dev/null
+++ b/WebFormBuilder/Examples/form.json
@@ -0,0 +1,41 @@
+{
+ "HtmlHeader": "<h1>Dit is een goede header</h1>",
+ "Action": "/api/SubmitForm",
+ "Change": "/api/SubmitValue",
+ "FieldSets": [
+ {
+ "Id": 1,
+ "Legend": "Naw gegevens",
+ "FormFields": [
+ {
+ "Name": "Naam"
+ },
+ {
+ "Name": "Adres"
+ },
+ {
+ "Name": "Woonplaats"
+ }
+ ]
+ },
+ {
+ "Id": 2,
+ "Legend": "Partner keuze",
+ "FormFields": [
+ {
+ "Type": "Radio",
+ "Name": "Partner"
+ }
+ ]
+ },
+ {
+ "Id": 3,
+ "Legend": "Partner gegevens",
+ "FormFields": [
+ {
+ "Name": "PartnerNaam"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/WebFormBuilder/Examples/formConfigData.json b/WebFormBuilder/Examples/formConfigData.json
index 1f53513..6345173 100644
--- a/WebFormBuilder/Examples/formConfigData.json
+++ b/WebFormBuilder/Examples/formConfigData.json
@@ -10,7 +10,7 @@
"Label": "UserName",
"Placeholder": "Enter your username",
"Tooltip": "This will be your unique identifier.",
- "Properties": [ "autocomplete=username", "required=yes" ],
+ "Properties": ["autocomplete=username", "required=yes" ],
"Value": "JohnDoe"
},
{
@@ -19,7 +19,7 @@
"Label": "Email Address",
"Placeholder": "Enter your email address",
"Tooltip": "We will send important updates to this email.",
- "Properties": [ "autocomplete=email" ],
+ "Properties": [ "autocomplete=email" , "hidden=hidden" ],
"Value": "example@example.com"
},
{
diff --git a/WebFormBuilder/Examples/text.json b/WebFormBuilder/Examples/text.json
index bcdd7d2..033bf52 100644
--- a/WebFormBuilder/Examples/text.json
+++ b/WebFormBuilder/Examples/text.json
@@ -10,22 +10,22 @@
},
{
"Type": "text",
- "Name": "text1"
+ "Name": "text2"
},
{
"Type": "text",
- "Name": "text2",
+ "Name": "text3",
"Label": "",
"Value": "some value"
},
{
"Type": "text",
- "Name": "text3",
+ "Name": "text4",
"Tooltip": "type some text"
},
{
"Type": "text",
- "Name": "text4",
+ "Name": "text5",
"Label": "Some label",
"Placeholder": "Placeholders are good"
}
diff --git a/WebFormBuilder/Models/FormField.cs b/WebFormBuilder/Models/FormField.cs
index 60952d9..27656a6 100644
--- a/WebFormBuilder/Models/FormField.cs
+++ b/WebFormBuilder/Models/FormField.cs
@@ -1,8 +1,20 @@
-using System.Text.Json.Serialization;
+namespace WebFormBuilder.Models;
-namespace WebFormBuilder.Models;
+public class Form
+{
+ public string HtmlHeader { get; set; } = string.Empty;
+ public string Action { get; set; } = string.Empty;
+ public string Change { get; set; } = string.Empty;
+ public List<FieldSet> FieldSets { get; set; } = [];
+}
+public class FieldSet
+{
+ public int Id { get; set; }
+ public string Legend { get; set; } = string.Empty;
+ public List<FormField> FormFields { get; set; } = [];
+}
public class FormField
{
diff --git a/WebFormBuilder/Program.cs b/WebFormBuilder/Program.cs
index 9b734ac..1425ac6 100644
--- a/WebFormBuilder/Program.cs
+++ b/WebFormBuilder/Program.cs
@@ -1,4 +1,63 @@
+using System.Text.Json;
using System.Text.Json.Serialization;
+using WebFormBuilder.Models;
+
+
+var fs1 = new FieldSet()
+{
+ Legend = "Of the fall",
+ FormFields = [ new ()
+ {
+ Name = "Naam"
+ },
+ new ()
+ {
+ Name = "Adres"
+ }, new ()
+ {
+ Name = "Woonplaats"
+ }]
+};
+var fs2 = new FieldSet()
+{
+ Legend = "Of the fall",
+ FormFields = [new ()
+ {
+ Type = HtmlInputType.Radio,
+ Name = "Partner"
+ }]
+};
+var fs3 = new FieldSet()
+{
+ Legend = "Of the fall",
+ FormFields = [new ()
+ {
+ Name = "PartnerNaam"
+ }]
+};
+
+var form = new Form()
+{
+ HtmlHeader = "<h1>Dit is een goede header</h1>",
+
+ Action = "/api/SubmitForm",
+
+ Change = "/api/SubmitValue",
+
+ FieldSets = [ fs1, fs2, fs3]
+};
+
+
+var json = JsonSerializer.Serialize(form, new JsonSerializerOptions
+{
+ WriteIndented = true,
+ DictionaryKeyPolicy = null,
+ PropertyNameCaseInsensitive = true,
+ DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
+});
+
+File.WriteAllText(@"c:\temp\form.json", json);
+
var builder = WebApplication.CreateBuilder(args);
diff --git a/WebFormBuilder/wwwroot/WebForm.css b/WebFormBuilder/wwwroot/WebForm.css
index d4e32ea..914e161 100644
--- a/WebFormBuilder/wwwroot/WebForm.css
+++ b/WebFormBuilder/wwwroot/WebForm.css
@@ -150,6 +150,13 @@ body
flex-direction: column;
}
+ .form-container fieldset
+ {
+ display: flex;
+ flex-direction: column;
+ border:none;
+ }
+
.form-container .radio-group,
.form-container .checkbox-group
{