Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Help Adding Fields

edited August 2006 in Vanilla 1.0 Help
As we know when you "Start a new discussion" you are taken to post.php which has the following form on the page. I would like to add fields to this page. I've not that good with PHP nad have been looking threw all the files in vanilla. and cant find the file to edit to add more fileds. Below is an example of what I want to do. i guess what I'm asking is what file to I edit to add more fields to the post form. Example=========================== Select the category for this discussion: (field) Enter your discussion topic: (field) Added Information: (field) Enter Your Comments: (Field) Thanks for you help:


  • First, you should consider if you want to do it as an extension (without really touching the core Vanilla files, which ensures portability with new versions or themes) or you prefer to touch directly the code here and there is the simplest possible way.

    I also think that the problem is not to add a field to a form. But probably to add the code which recieves the value and uses it to do something. Do you want to store it in the database, or what?

    Anyway, you should have a look at: themes/discussion_form.php
    You will find there the code which generates the HTML form for the default theme. You can add the field manually there (the dirty way).
    If you want to go the hard way and create an extension, you should create a function and add it to one of the delegates you will find in that file, without touching the file itself. You may have a look at the documentation or any simple extension to know how to do it.

    Then, in: library/Vanilla/Vanilla.Class.Discussion.php
    You will find the method GetPropertiesFromForm. This is the point where the data is retrieved and stored in fields of the object.
    However, if you want to avoid touching the code, you may add your extension function to the PreSaveDiscussion delegation found in the file library/Vanilla/Vanilla.Control.DiscussionForm.php.

    Hope it helps.
  • Thanks that helped alot.
This discussion has been closed.