It's actually easier than you might expect and you don't need javascript to get a basic version going.
I'll assume all you want is a form with a textbox and a submit button. The solution will take 2 parts:
1) first you need to create a DekiScript function that returns the form so it can be embedded
2) second, you need to provide a handler when the submit button is pressed
Creating a function is easy if you already know how to create Dream services. Follow the same procedure by derive from DekiExtService. Then add a DekiScript function that returns the form:
Code:
[DekiExtFunction]
public XDoc SubscribeForm() {
return new XDoc("html")
.Start("body")
.Start("form").Attr("method", "POST").Attr("action", Self.At("handler"))
.Value("Email address: ")
.Start("input").Attr("type", "text").Attr("name", "email").Attr("size", 60).End()
.Start("input").Attr("type", "submit").Attr("value", "Submit").End()
.End()
.End();
}
Now you need the handler part, which is just a regular Dream feature in the same service:
Code:
[DreamFeature("POST:handler", "handle form submit")]
public Yield PostHandler(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
string email = request.AsDocument()["email"].AsText()
response.Return(DreamMessage.Ok());
yield break;
}
That should get you going. Would love it if you could share your near final version on an FAQ page.