Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jamie 35 posts 87 karma points
    Feb 28, 2011 @ 10:22
    Jamie
    0

    Quick simple form input to email

    Hi I'm new to umbraco .. so forgive me if this isn't in the right forum location - I'm not sure where his would go. I want to know how I would go about having a page with what I would call 'arbitrary form fields' that when submitted can be collected and emailed to a set address.

    Given I have my head around the UI and using the backend, templates and thier inheritence, Document Types and to a large extent Datatypes. I think I'm ready to get into custom forms. But this seems really hard. I've been using the Creative WebStarter kit and I'm able to get in and mangle the code for the Contact Form (for some reason they have two adress fields but no phone number field). But changing the two code files each time seems a very un-umbraco like. Thier must be a simpler way.

    I've stumbeled accross Doc2Form which might suite my needs but I have found no useage examples I can follow to try it out. Is thier somthing else I should be searching for? Is my approach to this wrong?

    Maybe I'm just not getting 'it' somehow I feel that a Data Type should have an option to simply be an 'Input Type' and you set the type of data to be enterd, the position and style in a template like you would any other element.

    As a side note winge - I'm not a fan of XSLT - partly as it's new to me and I don't understand it but also as you try and learn from online so many examples don't work and the error messages are unclear - highly frustrating. This seems compounded by the changes to XSLT that umbraco has done over time and google searches seem to always find the old forums with 2008 questions and awnsers that don't work in modern versions.

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 28, 2011 @ 11:00
    Jonas Eriksson
    0

    Hi!

    You could write a simple Razor-macro, just like this:

    @if (!IsPost)
    {
        <form method="POST">
        Tell us what you think:<br/><textarea name="msg" rows="3" cols="40"></textarea><br/>
        Your name:<br/><input type="text" name="name"/><br/>
        <input type="submit" value="Send your message to us"/>
        </form>
    }
    else
    {
        var message = Request["msg"];
        var name = Request["name"];
        umbraco.library.SendMail("[email protected]","[email protected]","Message from " + name,message,false);
        <strong>Thank you for your message @name:</strong><br/>@message
    }

    Could be added as a macro - or inside a template (within <umbraco:macro runat="server" language="razor"></umbraco:macro>)

    Hope it helps,

    Jonas

Please Sign in or register to post replies

Write your reply to:

Draft