I'd like to make a contact form exactly like this page:
Of course changing the icon and where it gets sent to, but otherwise exactly the same look.
There must be a 'hello world' example with email address validations and multiple input fields that I'm missing.... It should be easy to format this with the new WebItem
, WebColumn
, WebRow
symbols in v13 right?
CloudDeploy@
WebColumn[{WebItem[Rasterize["My Icon"], {200}],
WebItem["Please leave a detailed comment in the space below:"],
FormControl[Dynamic[message],
FormObject[{"message",
"Please leave a detailed comment in the space below:"} ->
"String"]],
FormControl[Dynamic[address],
FormObject[{"email", "Email:*"} -> "String",
AppearanceRules -> <|"ItemLayout" -> "Vertical"|>]],
WebItem["Attachment:"],
WebRow[{WebItem[Checkbox[]], WebItem["I agree..."]}],
WebItem@
Button["Submit", SendMail[address, message], Background -> Red]},
Alignment -> Center]
Response
The first piece of code makes the form page as you show, but I don't see a "send to" address, it doesn't send results to my wolfram cloud email account either...
banner = URLExecute@"https://picsum.photos/300/150";
CloudDeploy[ (*where is the "to" email address?*)
FormFunction[{"Name" -> <|"Interpreter" -> "String", "Label" -> None|>,
"Email" -> <|"Interpreter" -> "EmailAddress", "Label" -> None|>,
"Message" -> <|"Interpreter" -> "TextArea",
"Hint" -> "Please leave a more detailed comment",
"Label" -> None|>,
"Agreed" -> <|"Interpreter" -> "Boolean",
"Label" -> "I agree to the resale of my data on the dark web"|>},
TemplateApply[
"Thanks ``! Your submission went through.", {#Name}] &,
FormLayoutFunction ->
With[{r = banner},
Function[
Column[{Item[r, Alignment -> Left], "Name", #["Name", "Control"],
"Email", #["Email", "Control"],
Spacer[{10, 5}], #["Message", "Control"],
Row@{#["Agreed", "Control"],
Spacer[10], #["Agreed", "Label"]}},
Alignment -> Left]]]], "testControl", Permissions -> "Public"]
Please excuse my nitpicking, but there are a few more tiny discrepancies:
- There is no drag and drop field.
- The email and name fields are not enforced (you can click submit without filling them out and the page reloads but doesn't highlight the incomplete fields)
- The background isn't white (and there's an extra Panel[] it looks like)
- The spacing and fonts are off (probably easy to fix this one)
- The gray bar at the bottom "made with wolfram" shouldn't be there... (I'm guessing that impossible to remove?)
The second piece of code (the fully-fleshed-out snippet) spews errors for me in desktop version 13.0 (and there are no controls in the generated page):