Jump to:

22977 Posts in 11742 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Database input

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 434 Views
  • Lemonie
    Avatar
    Community Member
    70 Posts

    Database input Link to this post

    Please bear with me as with everything else I am trying to teach myself how to do something I know nothing about :-S

    I have a database already set up and am wanting to add html input forms on my website. I already have 'userforms' but don't think there is an option to do this on there. Is there a simple solution or do I have to code the html and php myself? If so could you point me in the right direction please.

    Thank you.

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Database input Link to this post

    With the userforms you should be able to create almost any type of form on your webpage, without ever having to write any code yourself. For that to work, your page needs to be of the correct type (UserDefinedForm If I recall correctly).

    If you don't want that, you can create your own form, but you need to write some php. There's a fine tutorial here you can start with: http://www.ssbits.com/newbies/2010/creating-a-simple-contact-form/

    In both cases SilverStripe will create the proper HTML for you

  • Lemonie
    Avatar
    Community Member
    70 Posts

    Re: Database input Link to this post

    Thanks for the reply. I already have userforms set up but where do I put the php code to allow me to directly enter the information to my database?

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Database input Link to this post

    OK, I think I get it. What you'd do if you wanted to write specific data to your database, you'd start by creating a DataObject, that would create its own datatable, and then use its write() method to write your data to the database.

    The form you create doesn't differ much fro the contact form I pointed you to. The only big difference is you don't send an email, but save your values instead.

    I recall that the Generic View module was designed just for this. It lets you add, edit, delete from a frontend form. You'll find it here on Github: https://github.com/chillu/silverstripe-genericviews

    (I don't know if it is still supported, or ported to 3.0 yet)

  • Lemonie
    Avatar
    Community Member
    70 Posts

    Re: Database input Link to this post

    Thanks I understand better now. I have Data Object Manager installed but how do I access it, sorry I told you I didn't know much

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Database input Link to this post

    Yes, well, basically the same as you would add a ComplexTableField, instead you'd be calling it 'DataObjectManager' - assuming you are using ss2.4.7. You should find all info on creating DataObjects and relations (and the ComplexTableField in the tutorials. Uncle Cheese has his own section on this forum where you can post your questions about the DataObjectManager.

    I suggest taking it one step at the time - really understand the concept of silverstripe's datastructure, then implement the backend functionality (including your DataObjectManager), then build a FrontEnd contact form and step by step refactor it, or check out other modules, like the one I mentioned above.

    It 's a bit of a learning curve, but if you want to create your own modules, it really pays of to first follow what others have done or written...

    Good luck

    434 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.