Bug #2852

WFormModel issue / Wrong wording in widget gallery example

Added by Stefan Arndt over 8 years ago. Updated over 8 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


There is an issue related to your wording in the integration example (Wt Widget Gallery->Forms).

Using a FormModel and a View:

class MyModel : public Wt::WFormModel



static constexpr Field Title_Field = "article-title";

//static const Field Title_Field;


Your example ( says, it's totaly valid to use the c++11 approach. Well, I don't think so.

Try to set a model value from inside MyModel using "setValue(Title_Field,X)" and additionaly from the view via "model->setValue(MyModel::Title_Field,X)" and you end up with having 2 fields.

They are both named "article-title", but they are distinct, since you are using a "const char*" as Field-Type, which is itsel the key in your field map ( Because "static constexpr Field" does not guarantee the pointers to be equal, this leads to nasty bugs.

I would prefer defining the Field as std::string, but at least you might want to correct (or place an explicit hint) on your integration example, that the C++11-approach does not work.


Updated by Koen Deforche over 8 years ago

  • Status changed from New to InProgress
  • Target version set to 3.3.3

Updated by Koen Deforche over 8 years ago

  • Status changed from InProgress to Resolved


It's unfortunate that the C++11 short-cut cannot be taken (since constexpr will not generate the unique storage needed for our purposes). I'm removing this comment.

But I would prefer to stick to the 'const char *' based Fields, simply because it avoids a lot of string comparisons while trying to look-up a particular field. Using a std::string just seems like a large price to pay for minimal developer comfort improvements. But I realize it's debatable. I'm also updating the documentation of WFormModel to point out this caveat.




Updated by Koen Deforche over 8 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF