+ Reply to Thread
Results 1 to 10 of 13

Thread: Extension containing forms

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    83

    Default Extension containing forms

    I want to setup a registration extension on my dekiwiki web site.

    Basically a simple form with a "Subscribe" button.

    I've a Dream service to manage the database behind, but how can I link it into the dekiwiki interface ? What's the best way to do it with extensions ? I'm not a javascript expert...

    I you have some advice, code snipplets, ...

    Tks

  2. #2
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    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.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  3. #3
    Join Date
    Oct 2006
    Posts
    83

    Default

    ok, tks

    Will try to setup a faq when complete.

  4. #4
    Join Date
    Oct 2007
    Location
    Edmonton, Cananda
    Posts
    322

    Default

    Did you get this working? I'm very interested in having a form's input sent to a table in a wiki page, and hope this might be the direction I need to go.

    Edit: I can't read very well. The extension page for DHTML lists this exact example:

    http://wiki.opengarden.org/Deki_Wiki/Extensions/DHtml
    Last edited by jadus; 05-06-2008 at 10:13 PM. Reason: can't read

  5. #5
    Join Date
    Oct 2007
    Location
    Edmonton, Cananda
    Posts
    322

    Default

    I may have spoken too soon. The example of dhtml.table works great, however any information that is entered disappears after a page refresh, or if a user navigates away from the page and comes back. Is this by design, and is there any way to force the form entries to remain in the table?

  6. #6
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    DHtml is only for dynamic HTML. However, the code I provided above allows you to do server side processing using a .Net assembly.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts