Copied to clipboard

Flag this post as spam?

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


  • Evan 344 posts 99 karma points
    May 26, 2009 @ 19:39
    Evan
    0

    Need to create a form that submits to a database and can be displayed in the admin section..

    I am working on a website in 4.0.1 and I need to be able to have a form on a page where a user can fill out their name, phone number, address, and description, and when they submit the form have it store everything in the database as well as generate a type of log file that can be displayed on the admin home page (like the email a friend, contact in the cws). Where can I start with this?

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 26, 2009 @ 21:11
    Dirk De Grave
    0

    Hi,

    - First , create a user control for input of form data. It's the user control that takes care of storing data in the database (plain old asp.net...).

    Either user control and code behind file go into /usercontrols folder, or in case of a compiled assembly, dll goes into /bin folder and ascx user control in /usercontrols folder.

    - Create another user control that will serve as a dashboard control - that user control will list data stored in the database (which has been submitted through the form)

    Again, upload user control to the umbraco install (you're free to choose where to upload in this case, but would advice to also use the /usercontrols folder.

    Register the dashboard control in /config/dashboard.config

    [code]






    [/code]
    (Names can/should be changed of course according to your implementation)

    Feel free to ask more questions if not clear...

    Cheers,
    /Dirk

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    May 27, 2009 @ 09:22
    Ismail Mayat
    0

    EWatkins,

    Another way round this would be to create form as document type then use doc2form to render the form and store the form submission as node in separate part of the site under a root node. Make that node only accessible by admin. You could view items in the content tree.

    If you still want separate dashboard access to view then create a dashboard control with repeater on it use nodefactory to get items below that node and return them as datatable (method on node factory to return children as datatable) and bind to that. You could quite easily hack the code in doc2form to do the logging.

    Regards

    Ismail

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 27, 2009 @ 09:31
    Dirk De Grave
    0

    @Ismail: I'm confident your solution works out great, it will, but will create lots of overhead if data is stored as "documents" in umbraco. It would only take up space in the content xml (and more memory in case of big response...) which you'd avoid in a large and popular site?

    (Btw, I've also done it a couple of times the way you describe it, mea culpa. Not longer now...)

    Just my 2 cents

    Cheers,
    /Dirk

  • Jonas 49 posts 21 karma points
    May 27, 2009 @ 10:17
    Jonas
    0

    Dirk. Interesting. I like the idea of storing all kinds of data as Umbraco-documents, but I understand that it might cause overhead like you say. But - if one stores the specialized data-documents in another nodebranch than the main content nodebranch, would that help to keep overhead smaller?

    mysite / content / ...

    mysite / all-kinds-of-data / ...

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    May 27, 2009 @ 10:32
    Dirk De Grave
    0

    @prgjonas: Nope, unless you don't publish the 'all-kinds-of-data' documents.

    Cheers,
    /Dirk

  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    May 27, 2009 @ 11:45
    Ismail Mayat
    1

    @dirk,

    I have actionhandler setup to prevent publishing of form submissions, its private data i dont want it published thus its not in content xml. I also have subfolders in the form folder eg processed, spam. I also have tab on the form doc type called status that has drop down with statuses that map to folders so in my example the drop down would be spam, processed user can then select a status and save and actionhandler drops it into appropriate folder. As part of training the system admin is given guidance on clearing out old form data or moving it into appropriate folder.

    It depends really how much data your going to get the doc2form way is nice quick way of getting a form up. In the past where I have had to deal with large volumes of submissions i have gone down your suggested route and used subsonic scaffold as dashboard control for admin purposes.

    This is what i love about umbraco there is always more than one way to skin a cat!

    Regards

    Ismail

  • Evan 344 posts 99 karma points
    May 27, 2009 @ 19:12
    Evan
    0

    I have set up everything and I can get the form to write to an xml log file and display almost everything. To do this I modified Warren's contact form that comes with the cws, however I am having one small issue. Everything shows up fine in the xml, but one field is not being translated from the xml to the dashboard. I can see the field populated in the xml but I can not seem to figure out why it will not populate in the dashboard. I think the fields for the dashboard pull from logscript.js and this is what I have in there:
    $(".asset .form
    logs li").click(function() {

    var logName = $(this).find("ul li.name").text();
    var logPhone = $(this).find("ul li.Phone").text();
    var logAddressLine1 = $(this).find("ul li.addressLine1").text();
    var logAddressLine2 = $(this).find("ul li.addressLine2").text();
    var logEmail = $(this).find("ul li.email").text();
    var logMessage = $(this).find("ul li.message").text();

    $(".asset .displayLog span.name").text(logName);
    $(".asset .displayLog span.Phone").text(logPhone);
    $(".asset .displayLog span.addressLine1").text(logAddressLine1);
    $(".asset .displayLog span.addressLine2").text(logAddressLine2);
    $(".asset .displayLog span.email").text(logEmail);
    $(".asset .displayLog span.message").text(logMessage);


    //Remove selected class from previous item
    $(this).parents().find(".asset .form_logs li.selected").removeClass("selected");

    //Add selected class
    $(this).addClass("selected");

    return false;
    });

    Everything but Phone comes through. Any ideas?

  • Evan 344 posts 99 karma points
    May 27, 2009 @ 20:59
    Evan
    0

    Solved it, had to reload the cache!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies