22849 Posts in 9710 Topics by 2803 members
|Go to End|
20 September 2012 at 6:31pm
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.
20 September 2012 at 10:34pm
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
21 September 2012 at 11:31pm
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?
22 September 2012 at 4:05am
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)
22 September 2012 at 10:18am
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
22 September 2012 at 11:10pm
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...
|Go to Top|