c++formscppcms

Build error with forms in CppCMS


We are having troubles including a login form in our project. We follow the steps in http://cppcms.com/wikipp/en/page/cppcms_1x_forms

This is the definition of the form:

struct SignInFormInfo : public cppcms::form {
/* Error 1 */ cppcms::widgets::text user_name;
/* Error 2 */ cppcms::widgets::password password;
cppcms::widgets::submit submit;

SignInFormInfo() {
user_name.message("User name");
password.message("Password");
submit.value("Sign in");

add(user_name);
add(password);
add(submit);

// Restrictions
user_name.limits(1, 31);
password.non_empty();
}
};

and we get these build errors:

Error 1: The type 'cppcms::widgets::text' must implement the inherited pure virtual method 'cppcms::base_form::load'

Error 2: The type 'cppcms::widgets::password' must implement the inherited pure virtual method 'cppcms::widgets::base_widget::render_input'

We also get errors in the cppcms libraries "cppcms/form.h" and "booster/hold_ptr.h" about the variable "_data" being private.

We are using 1.0.3 version of CppCMS.

Thanks for your help


Solution

  • Wich "load" method should be used?

    the one from "base_html_input" class or the one from "base_text". There are 2 methods named "load" that comes from different classes (and both derived from same class!), both are base classes of the same class. The compiler simply don't know wich one to use. The best thing is to implement your self the "load".

    widgets::text::load(param) //actually missing in CPPCMS
    {
         //wich one of the 2 methods has to be called.. or both have to be called?
         base_html_input.load(param)
         base_text input.load(param);
    }
    

    That's probably a design flaw of the library you are using (unless there's somewhere a factory of "widgets::text" objects, that is returning objects with correct implementation, anyway the article with the tutorial is wrong.)