Re: [Cppcms-users] widgets::checkbox.value() always returns 0
Brought to you by:
artyom-beilis
From: Artyom <art...@ya...> - 2011-02-12 10:10:23
|
Hello, Show your code... 1. How do you configure your form (full code) 2. How do you load data to your form 3. How do you render your form Because I use checkbox on daily basis and it is covered by unit test. > > Checkbox is defined like this: > > cppcms::widgets::checkbox agree; > > Now check the posted form values: > > if(request().post().find("agree") != request().post().end()) > BOOSTER_LOG(debug,"agree") << request().post().find("agree")->second; > > and I see "on" in the log, but agree.value() always returns "0". > > Any idea? 1. All CppCMS 1.x.x widgets have automatic naming that are rendered and tested in form so basically if you use request().post().find("agree") != request().post().end() Then it seems that you do not create form by <% form ... %> tag. and you write your own code. In such case you should provide a name for checkbox: agree.name("agree"); 2. In addition it is also may be that you do not put all widgets in a single form and then they not get loaded. Take a look once again on the CppCMS sources examples/form/ On how do you render and configure the form. Artyom P.S.: Which reminds me there is need for up-to-date tutorial for CppCMS forms. |