revel

POST form with Revel


I'm trying to get the data from a POST form and display it in the same page with Revel.

What do I need to do to effectively pass the values from the html page to the Go controller?

Here is the HTML:

<form method="POST" action="/" id="doIt">
 <input type="text" name="sendIt" /> <br/>
 <input type="submit" value="send" />
</form>

And the Go:

func (c App) Index() revel.Result {

    dat := c.Params.Form.Get(doIt);

    return c.Render(dat)
}

EDIT: It seems POST and GET data are bound to Revel by their ID. Getting it right, I may find a solution!


Solution

  • It seems to work with the input tag rather than with the form... So this wolution works for me:

    func (c App) Index() revel.Result {
    
        dat := c.Params.Get(sendIt);
    
        return c.Render(dat)
    }