Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Adding a class to the comments input form itself
Is there a way to add a class to the <form>
tag that is output by comments_form
? I know I can add a class to the wraptag, but I’m talking about the <form>
tag itself.
I have tried to create my own <form>
tags to do this (I can get the action url from looking at the default one) but then any comments input tags don’t parse – I get an error for each one. Before I go down the track of manually creating the whole form (ie. including the input tags), I was just wondering if there is something I’m missing.
Can we add a class in this way using the built-in tags?
Offline
Re: Adding a class to the comments input form itself
Hi,
I think it’s not possible. Why do you want to do this?
It’s not neccessary for CSS or a JavaScript to must have a class attribute applied to this form.
What do you want to achieve with this class? Maybe there is a solution despite the class issue.
Offline
Offline
Re: Adding a class to the comments input form itself
Thanks for this – I’ll try it out tonight.
I’m such an old-fashioned HTML dude that I forget how easy it is to do this stuff in javascript. Mind you, I’ve always felt that there was something faintly suspicious about scripts working away behind the scenes where I can’t see them!
Offline
Re: Adding a class to the comments input form itself
aslsw66 wrote #278430:
I’m such an old-fashioned HTML dude that I forget how easy it is to do this stuff in javascript. Mind you, I’ve always felt that there was something faintly suspicious about scripts working away behind the scenes where I can’t see them!
You are not alone, we are about 2% to disable js while browsing. In case you care about these 2% (or don’t want to load jQuery), replace <txp:comments_form />
with
<txp:etc_query data='<txp:comments_form />'
replace="id('txpCommentInputForm')@@class=myClass" />
Offline
Re: Adding a class to the comments input form itself
aslsw66 wrote #278427:
Can we add a class in this way using the built-in tags?
I will readily +1 etc’s suggestions. You could also use rah_replace
(untested):
<txp:rah_replace from="<form" to='<form class="classname"'>
<txp:comments_form />
</txp:rah_replace>
I don’t recall if comments_form
has an in-built class – I don’t think it does – but it’s worth a shot.
Last edited by gaekwad (2014-01-24 14:18:05)
Offline
Re: Adding a class to the comments input form itself
Thanks for all three suggestions. I prefer either of the two non-JS dependent solutions, only because they are 100% safe.
I know that comments_form
doesn’t pass a class directly to the form, because I checked out the coding – it will only pass it to a wraptag
if one exists.
I’ll be testing the other two solutions later on. I think etc_query
looks harder, but will ultimately be more rewarding in terms of what it can do.
Offline
Re: Adding a class to the comments input form itself
aslsw66 wrote #278441:
I think
etc_query
looks harder, but will ultimately be more rewarding in terms of what it can do.
etc_query
makes you 27% more attractive, too.
Offline