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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

modify <input> value="" attribute for search form


Go to End


3 Posts   2075 Views

Avatar
AL

Community Member, 7 Posts

24 March 2011 at 1:58am

Hi,

I want to modify the <input value=""> for the search to display a "search now" message. But I don't know where should I do this.
Any word of advice?

Thanks

Avatar
schellmax

Community Member, 126 Posts

24 March 2011 at 6:51am

i don't like forms being generated by code, so usually i just build the html on my own.

so instead of using $SearchForm in your template, you could place the following there:

<form enctype="application/x-www-form-urlencoded" method="get" action="/sip_wagner/home/SearchForm" id="SearchForm_SearchForm">
	<fieldset>
		<legend></legend>
		
			<div class="field text  nolabel" id="Search"><div class="middleColumn"><input type="text" value="herr" name="Search" id="SearchForm_SearchForm_Search" class="text nolabel"></div></div>
		
			<input type="hidden" value="de_AT" name="locale" id="SearchForm_SearchForm_locale" class="hidden">
		
		
			<input type="submit" title="Go" value="Search Now" name="action_results" id="SearchForm_SearchForm_action_results" class="action ">
		
	</fieldset>
</form>

that's exactly the output of $SearchForm (have a look at the html $SearchForm generates by viewing the sourcecode of your page), only thing i modified is the button value, as you requested.

some might argue that this should be done modifying the code to generate the form itself, which you could do by extending the SearchForm class, just post back if you need any help there.

Avatar
AL

Community Member, 7 Posts

24 March 2011 at 8:47pm

Yes, is working perfectly!
I don't know why I've neglected viewing the page source :)

Thank you for the hints