Drogon template request for POST handling
I want a Drogon template for handling POST that looks like the README page below.
https://github.com/elanatframework/Web_forms_classes/blob/elanat_framework/php/README.md
The above page shows how to use WebForms Core technology in PHP.
WebForms Core is a modern technology for manipulating HTML tags through server code. In this technology, the WebForms class from the server communicates with the WebFormsJS library from the client automatically.
At Elanat, we want to make WebForms Core technology available to everyone for all programming languages. We did this for most of the popular programming languages and were able to test them. Unfortunately, after several days of trying for the programming language and C++, we were unable to test.
Now, we are asking Drogon developers or experts to use WebForms Core technology and test the PHP example in the Drogon framework.
The WebForms.h for C++ class is available via the link below.
https://github.com/elanatframework/Web_forms_classes/blob/elanat_framework/cpp/WebForms.h
The WebFormsJS library is also available at the link below.
https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js
The example below is an implementation of WebForms Core in a hypothetical framework in C++. The code related to WebForms is written correctly.
#include <iostream>
#include <string>
#include "backendframework.h" // A hypothetical framework
#include "WebForms.h"
using namespace std;
int main() {
// If is post method by submit form
if (responseForm.hasKey("btn_SetBodyValue")) {
int fontSize = std::stoi(responseForm.getValue("txt_BackgroundColor"));
std::string backgroundColor = responseForm.getValue("txt_BackgroundColor");
std::string name = responseForm.getValue("txt_Name");
WebForms form;
form.SetFontSize(InputPlace::Tag("form"), fontSize);
form.SetBackgroundColor(InputPlace::Tag("form"), backgroundColor);
form.SetDisabled(InputPlace::Tag("btn_SetBodyValue"), true);
form.AddTag(InputPlace::Tag("form"), "h3");
form.SetText(InputPlace::Tag("h3"), "Welcome " + name + "!");
form.AssignDelay(78);
std::cout << form.Response() << std::endl;
return 0;
}
// If is get method
std::cout << backEndRender("view")) << std::endl;
return 0;
}
##End
@@view
<!DOCTYPE html>
<html>
<head>
<title>Using WebForms Core</title>
<script type="text/javascript" src="/script/web-forms.js"></script>
</head>
<body>
<form method="post" action="/" >
<label for="txt_Name">Your Name</label>
<input name="txt_Name" id="txt_Name" type="text" />
<br>
<label for="txt_FontSize">Set Font Size</label>
<input name="txt_FontSize" id="txt_FontSize" type="number" value="16" min="10" max="36" />
<br>
<label for="txt_BackgroundColor">Set Background Color</label>
<input name="txt_BackgroundColor" id="txt_BackgroundColor" type="text" />
<br>
<input name="btn_SetBodyValue" type="submit" value="Click to send data" />
</form>
</body>
</html>