Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Inserting Drop Down Selector via HTML

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: 348 Views
  • goodness
    Avatar
    Community Member
    38 Posts

    Inserting Drop Down Selector via HTML Link to this post

    I am attempting to insert a drop down selector on a page within the CMS.
    I've tried using the HTML Source Editor on the page but with I click "Update" it strips out my code.

    My plan was to use this as a way to navigate to anchor tags within an FAQ page without listing out all of the questions at the top of the page as links.

    I was using code like this:

    <select name="selectionField">
    <option value="Question 1" ><a href="#quest1"Question One</a></option>
    <option value="Question 2" ><a href="#quest2">Question Two</a></option>
    <option value="Question 3" ><a href="#quest3">Question Three</a></option>
    </select>

    Any help will be greatly appreciated.

    Thanks!

  • goodness
    Avatar
    Community Member
    38 Posts

    Re: Inserting Drop Down Selector via HTML Link to this post

    I'm still trying to figure out how to get this on a page without the system stripping out the code.

    This code works in a stand-alone webpage:

    <form>
    <select name="faqForm" ONCHANGE="location = this.options[this.selectedIndex].value;">
    <option value="#">Select Your Question</option>
    <option value="#quest1">Question One</option>
    <option value="#quest2">Question Two</option>
    <option value="#quest3">Question Three</option>
    <option value="#quest4">Question Four</option>
    <option value="#quest5">Question Five</option>
    </select>
    </form>

    However, when I go into the HTML Source Editor (within the content area for the page) and type the above code in - the system strips it out as soon as I click Update. It converts it to this:

    <p>Select Your QuestionQuestion OneQuestion TwoQuestion ThreeQuestion FourQuestion Five</p>

    Is there a trick to getting the system to leave my code as is?

    Anyone?

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: Inserting Drop Down Selector via HTML Link to this post

    What you're looking for is "valid_elements" and "extended_valid_elements", options of tinyMCE.

    http://www.tinymce.com/wiki.php/Configuration:valid_elements
    http://www.tinymce.com/wiki.php/Configuration:extended_valid_elements

    You can set this options with:

    HtmlEditorConfig::get('cms')->setOptions();

    But I have to tell you: what you want to do is actually a bad idea. Especially the additional "form" tags in your code.

    You could simply write a method in your page class, which seeks your anchor tags in $this->Content() and return them as a DropdownField for the template.

    348 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.