Project

General

Profile

Use comboBox,checkbox and radioButton in the Wt::Auth::RegistrationWidget

Added by yyyy yyyy about 9 years ago

Hi, playing with the example/features/auth2, I want to show combobox, check box and radio box

on the registration form, but there some problems need to solve

case 1 : create checkbox(RegistrationView.cpp)

if(field == UserDetailsModel::FavouritePetField){

return new Wt::WCheckBox("check me");

}else{

return Wt::Auth::RegistrationWidget::createFormWidget(field);

}

I expect the checkbox will appear at the blue region, but it appear at red region as checkbox.JPG shown

case 2 : create comboBox(RegistrationView.cpp)

if(field == UserDetailsModel::FavouritePetField){

auto *box = new Wt::WComboBox;

box->addItem("one");

box->addItem("two");

return box;

}else{

return Wt::Auth::RegistrationWidget::createFormWidget(field);

}

Same as case 1, the combobox do not appear at the "correct" location(comboBox.JPG)

case 3 : create radioButton(RegistrationView.cpp)

if (field == UserDetailsModel::FavouritePetField){

auto *container = new Wt::WContainerWidget;

auto *group = new Wt::WButtonGroup(container);

group->addButton(new Wt::WRadioButton("Radio me",

container));

group->addButton(new Wt::WRadioButton("No, radio me",

container));

return group;

}else{

return Wt::Auth::RegistrationWidget::createFormWidget(field);

}

This will show compile time error "cannot convert from Wt::WButtonGroup to Wt::WFormWidget"

How could I solve it?Thanks


Replies (2)

RE: Use comboBox,checkbox and radioButton in the Wt::Auth::RegistrationWidget - Added by Koen Deforche almost 9 years ago

Hey,

1. You should use 'new WCheckBox()' without the additional label. It's because of the (redundant) label that the layout is confused. If you really insist on the second label then you need to fix this using CSS.

2. There is some CSS missing indeed to make this work out of the box (we're fixing this for 3.3.6), you can add this to your own stylesheet:

, .Wt-form .Wt-fields select{
    float: left;
    padding: 5px 2px;
    border: solid 1px #aacfe4;
    font-size: 90%;
    width: 14em;
    margin: 0.5em 0.5em 1.4em 0.7em;
}

3. The return type should indeed be WWidget, it seems that this wasn't fixed in Wt::Auth. This will be fixed in 3.3.6 too.

RE: Use comboBox,checkbox and radioButton in the Wt::Auth::RegistrationWidget - Added by yyyy yyyy almost 9 years ago

Thanks, the CSS solved my problem, it would be better if the box could place higher(I change padding and margin, but do not work as expected).

Looking forward to the next release of Wt.

    (1-2/2)