Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Form Questions
SilverStripe Forums » Form Questions » How to take out 'Form Legend' tag
| Go to End | Next > | |
| Author | Topic: How to take out 'Form Legend' tag | 1376 Views |
-
How to take out 'Form Legend' tag

22 December 2008 at 2:28pm
I have followed the tutorial on how to create a site search form. For some reason, it created a 'legend' tag with a border around the search form.
I found a tip from the forum, to create a new SearchForm.ss
<form $FormAttributes>
<% control Fields %>
$FieldHolder
<% end_control %><% control Actions %>
$Field
<% end_control %>
</form>Does anyone know how to remove this tag easily, without having to write a new template?
Thanks!
-
Re: How to take out 'Form Legend' tag

27 December 2008 at 10:32pm
I don't think there is a way.
Previous versions of Silverstripe did not have a legend tag at all in the forms - which made them fail html validation.
If you want to get rid of the border, you could probably just do that with CSS:
legend{ display:none; }
or something...
I'm not sure why a legend would create a border by default - that sounds more like something that a <fieldset> would do...
-
Re: How to take out 'Form Legend' tag

24 January 2009 at 6:52pm
Yes would really like that.
I wanted to have little more control over the looks and feel of the search text box.
Woluld be glad if someone can point out where to look for. -
Re: How to take out 'Form Legend' tag

27 January 2009 at 11:52pm
I am having the same issue, but I have solved part of it.
You can get rid of the border by adding a CSS element for the fieldset (which is where the border is being set by the user agent) :
#Header form fieldset {
border: none;
}As for the word "Search" appearing, I am a bit baffled. I've tried tracking back to see where this originates, but no luck. I looked at SearchForm.php but that doesn't seem to be the source.
Can anyone tell me where in the code this caption gets inserted?
Ian.
-- -
Re: How to take out 'Form Legend' tag

28 January 2009 at 12:04am Last edited: 28 January 2009 12:05am
'Search' comes from the code in your controller probably something like
$fields = new FieldSet(
new TextField("Search","Search");
);The second 'search' is the label.
For changing the look and feel of it, CSS is really what you're looking for.
Setting a legend can be done with
$FormObject->setLegend("Value");
-
Re: How to take out 'Form Legend' tag

28 January 2009 at 12:26am
No, I don't think that is the source. I have already removed those references from the controller. Here is my code in the controller:
function SearchForm() {
$searchText = isset($this->Query) ? $this->Query : '';
$fields = new FieldSet(
new TextField("", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'Search')
);
return new SearchForm($this, "SearchForm", $fields, $actions);
}I notice the syntax of the TextField method is different in your suggestion. But I tried pasting in what you wrote and it made no difference.
Regarding the setLegend command, how do you use this? I tried
$fields->setLegend("")
in the SearchForm function, but this throws a Big Red Error "Method 'setLegend' not found in class 'FieldSet'.
Any ideas where I am going wrong?
Thanks,
Ian.
-- -
Re: How to take out 'Form Legend' tag

28 January 2009 at 12:31am
Not sure about which search you're talking?
Do you have some url or code to look into?
The textfield 'Search' sets the label, the 'Search' on the button is by the action.
-
Re: How to take out 'Form Legend' tag

28 January 2009 at 4:00am
I have been following the tutorials from the silverstripe.org website. Tutorial 4 is the one that deals with creating a site search. I've basically abandoned worrying about this unwanted caption for now - I'll come back to it when I have some spare time. Thanks for looking anyway.
Ian.
--
| 1376 Views | ||
| Go to Top | Next > |
Currently Online: Euphemismus
Welcome to our latest member: fearofbuttons




