1 -- luacheck: ignore 212/self
3 local function new_simple_form(form
, result_handler
)
4 return function(self
, data
, state
)
6 if data
.action
== "cancel" then
7 return { status
= "canceled" };
9 local fields
, err
= form
:data(data
.form
);
10 return result_handler(fields
, err
, data
);
12 return { status
= "executing", actions
= {"next", "complete", default
= "complete"}, form
= form
}, "executing";
17 local function new_initial_data_form(form
, initial_data
, result_handler
)
18 return function(self
, data
, state
)
20 if data
.action
== "cancel" then
21 return { status
= "canceled" };
23 local fields
, err
= form
:data(data
.form
);
24 return result_handler(fields
, err
, data
);
26 return { status
= "executing", actions
= {"next", "complete", default
= "complete"},
27 form
= { layout
= form
, values
= initial_data(data
) } }, "executing";
32 return { new_simple_form
= new_simple_form
,
33 new_initial_data_form
= new_initial_data_form
};