Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Assigning a _class_ to search form
Using the txp tag of <txp:search_input />
generates a form (amongst other things), and I know it is possible to assign an id as per the docs: html_id="id"
Is it possible to give the generated form a class?
Or, should I write the search form long-hand?
Offline
Re: Assigning a _class_ to search form
Maybe:
<txp:search_input wraptag="form" class="some_class_name" />
But I would build the whole widget myself. By default, it appears that the tag looks for a form named search_input
(I didn’t know that until recently). See here for the form used by the default TXP theme . but you can name the form anything you want.
<txp:search_input form="some_name" />
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Assigning a _class_ to search form
Thank you phiw13
This is where I really wish the txp ‘forms’ had been called ‘snippets’ or something else
I was actually wondering about the html form
which is generated…
Do I have to edit it here?
<form class="my-class" action="<txp:site_url />">
<input name="q" type="search" />
</form>
Offline
Re: Assigning a _class_ to search form
Your suggestion to add a wrap tag then adds two forms…
<txp:search_input wraptag="form" class="some_class_name" />
And then the generated code is:
<form method="get" action="<txp:site_url />">
<form class="some_class_name">Search<br />
<input name="q" type="search" size="15" required="required" value="" /></form>
</form>
Offline
Re: Assigning a _class_ to search form
Ooops! Answered it myself, and added the class to the customised search_input
form :
<form class="some_class_name" action="<txp:site_url />">
<input class="form-control" type="text" name="q" />
</form>
Offline
#6 2018-06-18 13:42:41
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Assigning a _class_ to search form
Similar to your situation. Applied to the search form:
<txp:php>echo preg_replace('/id="YOUR_ID"/','id="YOUR_ID" class="YOUR_CLASS"', parse('<txp:search_input html_id="YOUR_ID" />'));</txp:php>
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#7 2018-06-18 13:44:33
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Assigning a _class_ to search form
gavnosis wrote #312618:
Ooops! Answered it myself, and added the class to the customised
search_input
form :
<form class="some_class_name" action="<txp:site_url />">...
Applies the class to the wraptag, not to the form itself.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Assigning a _class_ to search form
One day I’ll learn to think as elegantly as this! Thank you
Offline
Re: Assigning a _class_ to search form
Would rah_replace be helpful in this scenario?
Offline
Pages: 1