Skip to content

Commit

Permalink
[feature] WFormBuidler: Support for multiple file-upload fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
akoprow committed Jul 25, 2011
1 parent 434495f commit 3b9421e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
27 changes: 12 additions & 15 deletions stdlib/widgets/formbuilder/formbuilder.opa
Expand Up @@ -404,21 +404,18 @@ WFormBuilder =
| ~{ fragment } -> fragment
| ~{ field } -> mk_field(field)
body_form = <>{List.map(mk_element, spec.elts)}</>
match upload_fields_no(spec) with
| 0 ->
<form id={spec.form_id} action="#" onsubmit={_ -> process({SimpleForm})}
method="get" options:onsubmit="prevent_default">
{body_form}
</form>
| 1 ->
process(data) =
do Scheduler.push( -> process({FileUploadForm=data}))
void
config = {Upload.default_config() with
~body_form ~process form_id=spec.form_id}
Upload.html(config)
| _ ->
@todo //("WFormBuilder: forms with more than 1 upload fields are not (yet) supported")
if upload_fields_no(spec) == 0 then
<form id={spec.form_id} action="#" onsubmit={_ -> process({SimpleForm})}
method="get" options:onsubmit="prevent_default">
{body_form}
</form>
else
process(data) =
do Scheduler.push( -> process({FileUploadForm=data}))
void
config = {Upload.default_config() with
~body_form ~process form_id=spec.form_id}
Upload.html(config)

start(spec : WFormBuilder.specification) : void =
is_field =
Expand Down
11 changes: 6 additions & 5 deletions stdlib/widgets/formbuilder/formbuilder_template_engine.opa
Expand Up @@ -64,11 +64,12 @@ FormBuilderTemplate =
| {some=fb_tag} ->
match fb_tag with
| {form} ->
fields = [] // FIXME
process(_) = @todo
spec = FB.create_specification(Dom.fresh_id(), fields)
form = FB.html(spec, process)
{success = form}
// FIXME
fields = []
process(_) = void
spec = FB.create_specification(Dom.fresh_id(), fields)
form = FB.html(spec, process)
{success = form}

engine : Template.engine =
{ Template.empty with ~parse ~export }
Expand Down

0 comments on commit 3b9421e

Please sign in to comment.