mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-06 17:51:36 +02:00
Form class initial "sketch".
This commit is contained in:
parent
53a2a651d6
commit
f9dcdbb905
1
core/form.cpp
Normal file
1
core/form.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "form.h"
|
52
core/form.h
Normal file
52
core/form.h
Normal 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
|
@ -1,5 +1,7 @@
|
|||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
|
#include "form.h"
|
||||||
|
|
||||||
Theme::Theme() {
|
Theme::Theme() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +32,10 @@ void SiteTheme::render_index_page(Request *request, std::string *output) {
|
|||||||
add_footer(request, output);
|
add_footer(request, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SiteTheme::render_form(Request *request, Form* form, std::string *output) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SiteTheme::SiteTheme() {
|
SiteTheme::SiteTheme() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
class Form;
|
||||||
|
|
||||||
#define THEME_CORE(_class_name) \
|
#define THEME_CORE(_class_name) \
|
||||||
public: \
|
public: \
|
||||||
std::string theme_name; \
|
std::string theme_name; \
|
||||||
@ -57,6 +59,8 @@ public:
|
|||||||
|
|
||||||
virtual void render_index_page(Request *request, std::string *output);
|
virtual void render_index_page(Request *request, std::string *output);
|
||||||
|
|
||||||
|
virtual void render_form(Request *request, Form* form, std::string *output);
|
||||||
|
|
||||||
SiteTheme();
|
SiteTheme();
|
||||||
~SiteTheme();
|
~SiteTheme();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user