API CHANGE Deprecated FormField->describe(), use setDescription() instead. Actually use the description in form fields other than FormAction.

This commit is contained in:
Ingo Schommer 2012-03-07 11:54:48 +01:00
parent 69a8659a3d
commit 55a0fb18e4
3 changed files with 15 additions and 6 deletions

View File

@ -337,6 +337,7 @@ class FormField extends RequestHandler {
'id' => $this->ID(),
'tabindex' => $this->getTabIndex(),
'disabled' => $this->isDisabled(),
'title' => $this->getDescription(),
);
return array_merge($attrs, $this->attributes);
}
@ -689,14 +690,22 @@ class FormField extends RequestHandler {
return true;
}
/**
* @deprecated 3.0 Use setDescription()
*/
function describe($description) {
Deprecation::notice('3.0', 'Use setDescription()');
$this->setDescription($description);
return $this;
}
/**
* Describe this field, provide help text for it.
* The function returns this so it can be used like this:
* $action = FormAction::create('submit', 'Submit')->describe("Send your changes to be approved")
* By default, renders as a "title" attribute on the form field.
*
* @return string Description
*/
function describe($description) {
function setDescription($description) {
$this->description = $description;
return $this;
}

View File

@ -1,4 +1,4 @@
<ul id="$ID" class="$extraClass">
<ul id="$ID" class="$extraClass"<% if Description %> title="$Description"<% end_if %>>
<% if Options.Count %>
<% control Options %>
<li class="$Class">

View File

@ -1,4 +1,4 @@
<ul id="$ID" class="$extraClass">
<ul id="$ID" class="$extraClass"<% if Description %> title="$Description"<% end_if %>>
<% control Options %>
<li class="$Class">
<input id="$ID" class="radio" name="$Name" type="radio" value="$Value"<% if isChecked %> checked<% end_if %><% if isDisabled %> disabled<% end_if %>>