Form class initial "sketch".

This commit is contained in:
Relintai 2020-12-04 14:47:51 +01:00
parent 53a2a651d6
commit f9dcdbb905
4 changed files with 63 additions and 0 deletions

1
core/form.cpp Normal file
View File

@ -0,0 +1 @@
#include "form.h"

52
core/form.h Normal file
View File

@ -0,0 +1,52 @@
#ifndef FORM_H
#define FORM_H
#include <map>
#include <string>
#include <vector>
class Request;
class FormField {
public:
std::string name;
std::string label;
std::map<std::string, std::string> attribues;
virtual std::string render();
//checks if form field validates
virtual bool validate_check(Request *request);
//checks if form field validates, and returns human readable errorsm if any
virtual std::vector<std::string> validate_report(Request *request);
FormField();
virtual ~FormField();
};
class InputFormField : public FormField {
std::string render();
};
class InputTextFormField : public InputFormField {
std::string render();
};
class InputPasswordFormField : public InputFormField {
std::string render();
};
class Form {
public:
std::string name;
std::map<std::string, std::string> attribues;
std::vector<FormField *> fields;
//call Theme->render(); in it, and that will go though all attribs and call their renders
virtual std::string render();
Form();
virtual ~Form();
};
#endif

View File

@ -1,5 +1,7 @@
#include "theme.h"
#include "form.h"
Theme::Theme() {
}
@ -30,6 +32,10 @@ void SiteTheme::render_index_page(Request *request, std::string *output) {
add_footer(request, output);
}
void SiteTheme::render_form(Request *request, Form* form, std::string *output) {
}
SiteTheme::SiteTheme() {
}

View File

@ -5,6 +5,8 @@
#include <map>
#include <string>
class Form;
#define THEME_CORE(_class_name) \
public: \
std::string theme_name; \
@ -57,6 +59,8 @@ public:
virtual void render_index_page(Request *request, std::string *output);
virtual void render_form(Request *request, Form* form, std::string *output);
SiteTheme();
~SiteTheme();
};