Jump to:

23454 Posts in 18904 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » question about create form url

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: 994 Views
  • Jin
    Avatar
    Community Member
    2 Posts

    question about create form url Link to this post

    I have a search form object, and I need to build some links that post to that form. eg:

    I need a link like:
    <a href="www.domain.com/Page_Controller/SearchForm?keywords=xxxx">xxxx</a>

    I don't want to hardcode in case the form's name or other things changed. is there any other way to create a link?
    like: searchForm.Link("xxxx") will build a link. In orther to write such a funcion, what do I need?

    I am quite new to silverstripe, thanks for help. please give me some clues.

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: question about create form url Link to this post

    hi,

    a good question. I will just tell you with I will do. There can be a separate page type for the form; which you can define. On a very basic level (top of the hierarchy / Page.php) you can have a method to get the URL of the form pages controller. I think it is unlikely to change the form name; so you can hard code it. As the controller can change you might get it from the DataObjects.

    Or else you can get the form. and the form object itself has methods to retrieve the form name.

    refer to the Form documentation from the API.

    http://api.silverstripe.com/sapphire/forms/Form.html

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