Wt
4.11.1
|
A model class to represent database objects. More...
#include <Wt/Form/Dbo/FormModel.h>
Public Member Functions | |
FormModel (Wt::Dbo::Session &session, Wt::Dbo::ptr< C > ptr=nullptr) | |
Constructor. More... | |
void | addDboField (Wt::WFormModel::Field field) |
Adds a Dbo column as a field. More... | |
void | addDboFields (std::vector< Wt::WFormModel::Field > fields) |
Adds a list of Dbo columns to the model. More... | |
void | addAllDboColumnsAsFields (Wt::WFlags< FieldOptions > options=Wt::WFlags< FieldOptions >()) |
Adds all Dbo columns to the model. More... | |
void | initDboValues () |
Initializes the model with values from the database. | |
void | saveDboValues () |
Saves the changes made in the model to the database. | |
bool | validateField (Wt::WFormModel::Field field) override |
Validates a field. | |
Wt::Dbo::Session & | session () const |
Returns the Session object used by this class. | |
const Wt::Dbo::ptr< C > & | item () const |
Returns the database object used by this class. | |
Public Member Functions inherited from Wt::Form::Dbo::FormModelBase | |
FormModelBase () | |
Constructor. More... | |
const std::vector< std::string > & | dboFields () const |
Returns the Dbo columns used in this model. | |
Public Member Functions inherited from Wt::WFormModel | |
WFormModel () | |
Constructor. More... | |
void | addField (Field field, const WString &info=WString::Empty) |
Adds a field. More... | |
void | removeField (Field field) |
Removes a field. More... | |
std::vector< Field > | fields () const |
Returns the fields. More... | |
virtual void | reset () |
Resets the model. More... | |
virtual bool | validate () |
Validates the current input. More... | |
bool | valid () const |
Returns the current overall validation state. More... | |
void | setVisible (Field field, bool visible) |
Sets whether a field is visible. More... | |
virtual bool | isVisible (Field field) const |
Returns whether a field is visible. More... | |
void | setReadOnly (Field field, bool readOnly) |
Sets whether a field is read-only. More... | |
virtual bool | isReadOnly (Field field) const |
Returns whether a field is read only. More... | |
virtual WString | label (Field field) const |
Returns a field label. More... | |
virtual void | setValue (Field field, const cpp17::any &value) |
Sets the field value. More... | |
virtual const cpp17::any & | value (Field field) const |
Returns the field value. More... | |
virtual WString | valueText (Field field) const |
Returns the field value text. More... | |
virtual void | setValidator (Field field, const std::shared_ptr< WValidator > &validator) |
Sets a validator. | |
virtual std::shared_ptr< WValidator > | validator (Field field) const |
Returns a validator. More... | |
virtual void | setValidated (Field field, bool validated) |
Sets whether a field has been validated. More... | |
virtual bool | isValidated (Field field) const |
Returns whether the field has been validated yet. More... | |
const WValidator::Result & | validation (Field field) const |
Returns the result of a validation. More... | |
virtual void | setValidation (Field field, const WValidator::Result &result) |
Sets the validation result for a field. More... | |
Public Member Functions inherited from Wt::WObject | |
void | addChild (std::unique_ptr< WObject > child) |
Add a child WObject whose lifetime is determined by this WObject. | |
template<typename Child > | |
Child * | addChild (std::unique_ptr< Child > child) |
Add a child WObject, returning a raw pointer. More... | |
std::unique_ptr< WObject > | removeChild (WObject *child) |
Remove a child WObject, so its lifetime is no longer determined by this WObject. | |
template<typename Child > | |
std::unique_ptr< Child > | removeChild (Child *child) |
Remove a child WObject, so its lifetime is no longer determined by this WObject. More... | |
virtual const std::string | id () const |
Returns the (unique) identifier for this object. More... | |
virtual void | setObjectName (const std::string &name) |
Sets an object name. More... | |
virtual std::string | objectName () const |
Returns the object name. More... | |
void | resetLearnedSlots () |
Resets learned stateless slot implementations. More... | |
template<class T > | |
void | resetLearnedSlot (void(T::*method)()) |
Resets a learned stateless slot implementation. More... | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)()) |
Declares a slot to be stateless and learn client-side behaviour on first invocation. More... | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
Declares a slot to be stateless and learn client-side behaviour in advance. More... | |
void | isNotStateless () |
Marks the current function as not stateless. More... | |
template<class T > | |
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
Provides a JavaScript implementation for a method. More... | |
Public Member Functions inherited from Wt::Core::observable | |
observable () noexcept | |
Default constructor. | |
virtual | ~observable () |
Destructor. More... | |
template<typename... Args, typename C > | |
auto | bindSafe (void(C::*method)(Args...)) noexcept |
Protects a method call against object destruction. More... | |
template<typename... Args, typename C > | |
auto | bindSafe (void(C::*method)(Args...) const) const noexcept |
Protects a const method call against object destruction. More... | |
template<typename Function > | |
auto | bindSafe (const Function &function) noexcept |
Protects a function against object destruction. More... | |
Additional Inherited Members | |
Public Types inherited from Wt::WFormModel | |
typedef const char * | Field |
A type to identify a field. More... | |
Public Types inherited from Wt::WObject | |
typedef void(WObject::* | Method) () |
Typedef for a WObject method without arguments. | |
Protected Member Functions inherited from Wt::Form::Dbo::FormModelBase | |
void | insertDboField (Wt::WFormModel::Field field) |
Adds a Dbo column as a field. | |
Protected Member Functions inherited from Wt::WObject | |
virtual WStatelessSlot * | getStateless (Method method) |
On-demand stateless slot implementation. More... | |
A model class to represent database objects.
This implements field data and validation handling for database form-based views.
The user needs to add all database columns to the model that they want to display in the view before initializing the model. During initialization the model will read the information from the database.
|
explicit |
Constructor.
Creates a new form model
void Wt::Form::Dbo::FormModel< C >::addAllDboColumnsAsFields | ( | Wt::WFlags< FieldOptions > | options = Wt::WFlags<FieldOptions>() | ) |
Adds all Dbo columns to the model.
WException | when the method is called after initDboValues |
void Wt::Form::Dbo::FormModel< C >::addDboField | ( | Wt::WFormModel< C >::Field | field | ) |
Adds a Dbo column as a field.
WException | when the method is called after initDboValues |
void Wt::Form::Dbo::FormModel< C >::addDboFields | ( | std::vector< Wt::WFormModel< C >::Field > | fields | ) |
Adds a list of Dbo columns to the model.
WException | when the method is called after initDboValues |