Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

question about create form url


Reply


2 Posts   1062 Views

Avatar
Jin

Community Member, 2 Posts

16 October 2009 at 3:43pm

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.

Avatar
Nivanka

Community Member, 400 Posts

17 October 2009 at 12:38am

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.

[url]http://api.silverstripe.com/sapphire/forms/Form.html[/url]