Re: [Cppcms-users] Form Rendering
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-05-22 17:13:51
|
> > 1.) I would like to render a form and make a layout of them using css. As I > see, there are currently following options: > html_list_type { > as_p = 0, as_table = 1, as_ul = 2, as_dl = 3, > as_space = 4 > } > > as shown in: > http://cppcms.com/cppcms_ref/latest/structcppcms_1_1form__flags.html#a0c305033878375311a7d5df068eef974 > > Is it possible to render them as_div to get <div> sections? > > You can implement custom rendering they way you wish <% template divrender(cppcms::form &aform) %> <% foreach w as cppcms::form::iterator in aform %> <% item %> <div> <% if w.has_message() %><%= w.message() %>:<% end %> <% form input w %> <% if not w.valid() %>:<%= w.error_message() %><% end %> </div> <% end %> <% end %> <% end template %> > > 2.) Even if I add forms to forms it seems like that they seem to be rendered > completely flat. Yes because cppcms::form iterator iterates over all sub-widgets tree. > > Is it possible to somehow have the same structure in the html output like > the the forms have? > > e.g. I would like to generate following html: > <div> > <div> > element1 element2 > </div> > <div> > element3 element4 > </div> > </div> > > out of: > form1.add(element1); > form1.add(element2); > add(form1); > form2.add(element3); > form2.add(element4); > add(form2); > > (the othermost <div> is from the template) > Organize widgets into subforms and render them separately. <div> <% include divrender(form1) %> </div> <div> <% include divrender(form2) %> </div> You can also put the pointers/references on them in sime list/array and use foreach > > best regards > Markus Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |