buttonTag() got it.
# cfwheels
d
buttonTag() got it.
a
What does
buttonTag
give you over
<input type="reset">
?
p
The buttonTag() function has a
type
attribute that can take
button
,
reset
, or
submit
as inputs. It defaults to button if nothing is passed in.
a
yeah but what benefit does using
buttonTag
give one that just using mark-up? In what way does this helper "help" in this situation?
p
Historically I've used the form helper tags for two things one to encode the contents to prevent Cross Site Scripting attacks and the other for the prepend and append attributes that allow to wrap the input tag with HTML that could be used for styling the element like wrapping the Input tag with the label tag or other Bootsrap markup. The value to add that on each and every formtag helper in not much but if you setup defaults for the prepend and append attributes then simply calling the form helper will output the rest of the html markup as well. You could put this in you config/settings.cfm file:
Copy code
// Text/select/password/file Fields
	set(functionName="textField,textFieldTag,select,selectTag,passwordField,passwordFieldTag,textArea,textAreaTag,fileFieldTag,fileField",
		class="form-control",
		labelClass="control-label",
		labelPlacement="before",
		prependToLabel="<div class='form-group'>",
		prepend="<div class=''>",
		append="</div></div>",
		encode="attributes"  );
Then in your view you could have a call like this:
Copy code
#textFieldTag(name="q", value=params.q, label="Keyword Search", labelClass="sr-only", placeholder="Keyword")#
That automatically wraps the input tag with the html markup without having to repeat that.
a
I see.
I always question whether that sort of thing is a good implementation of the concept of "DRY". Mark-up doesn't really have sufficient complexity to warrant hiding it away like that, I think. But anyway: question answered, cheers. I thought I was missing something, but... no.
d
I just needed to create a reset button that only reset the form elements inside a fieldset.
I debated just using markup similarly to the discussion above. In the end I went with buttontag for readability.
1