Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262553
multiform.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
multiform.ts
View Options
import
{
curryImportPath
}
from
"../utils/utils"
;
export
async
function
multiformTemplate
(
action_name
:
string
,
newfilefullpath
:
string
)
:
Promise
<
string
>
{
const
rel
=
curryImportPath
(
newfilefullpath
);
return
`import { Context } from "koa";
import html from "
${
rel
(
"src/back/html.js"
)
}
";
import { Controls, Fields, Form, FormMessage, Multiform } from "@sealcode/sealgen";
import { FlatTemplatable } from "tempstream";
export const actionName = "
${
action_name
}
";
const fields1 = {
email: new Fields.SimpleFormField(true),
password: new Fields.SimpleFormField(true),
};
const form1 = new (class extends Form<typeof fields1> {
defaultSuccessMessage = "Form1 done!";
controls = [
new Controls.FormHeader("form1"),
new Controls.SimpleInput(fields1.email),
];
fields = fields1;
onSubmit() {
console.log("form1 submit");
}
})();
const fields2 = {
name: new Fields.SimpleFormField(true),
surname: new Fields.SimpleFormField(true),
};
const form2 = new (class extends Form<Record<never, unknown>> {
defaultSuccessMessage = "Form2 done!";
controls = [new Controls.FormHeader("form2"), new Controls.SimpleInput(fields2.name)];
fields = fields2;
onSubmit() {
console.log("form2 submit");
}
})();
export default new (class extends Multiform {
name = "multiform_test";
forms = { form1, form2 };
async render(
ctx: Context,
messages: FormMessage[],
prerenderedForms?: Record<string, FlatTemplatable | undefined>
): Promise<FlatTemplatable> {
return html(ctx, "
${
action_name
}
", await super.render(ctx, messages, prerenderedForms));
}
})();
`
;
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 15:15 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601606
Default Alt Text
multiform.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment