Re: [Erlangweb-users] "checked" radio buttons by default on forms
Brought to you by:
etcerlangweb,
paulgray
|
From: Michal Z. <mic...@er...> - 2008-11-18 08:20:10
|
Ad. 1.
As I suggested, to build form with already set values we need new function in controller. For now there is, in example, static call to 'add' function and dynamic to 'create'. We need to change add (which displays empty form) into dynamic in dispatcher. In that case, before building form we will go to controller to function 'add' and there we will set initial values for form.
Code could look like that:
add_person(_) ->
Default = prepare_defaults(),
wpart:fset("__edit", Deafault),
{template, "add_person.html"}.
prepare_defaults() ->
wpart_db:build_record_structure(person, initial, #person{name="", sex = "true"}).
%% wpart_db is generic module which builds long names (build by wpart_form)
Now when we have dynamically build form we can handle errors here as well. Try to experiment with validate_tool and request dictionary variable "__not_validated". On validation error there is set of posted values ready to render in form.
Ad 2.
Again, example was supposed to be very simple. For now I didn't have time to check it correctness. Sorry for troubles, again;) and thanks for feedback!
I can say how it works in real projects. For pagination is responsible wpart_paginate. It is in specific slot in View template. There is big chance that generic paginator will be added to version 1.2. It talks to Model and thanks to that knows specification of content of each page to render.
What was over-simplified in example is:
- mixed up functionality.
- html build in erlang function (separate wpart would use mechanism of loading .tpl and handling just arguments)
|