API CHANGE Deprecated FormField->getTabIndex()/setTabIndex(), use getAttribute()/setAttribute() instead. Removed FormField->getTabIndexHTML()

This commit is contained in:
Ingo Schommer 2012-03-07 17:45:14 +01:00
parent 9a96b92c81
commit 391ffde4f3
3 changed files with 25 additions and 22 deletions

View File

@ -113,7 +113,7 @@ class ConfirmedPasswordField extends FormField {
}
$content .= "<div class=\"showOnClick\">\n";
$content .= "<a href=\"#\"" . $this->getTabIndexHTML() . ">{$title}</a>\n";
$content .= "<a href=\"#\">{$title}</a>\n";
$content .= "<div class=\"showOnClickContainer\">";
}

View File

@ -19,6 +19,17 @@ class CreditCardField extends TextField {
return $field;
}
/**
* Get tabindex HTML string
*
* @param int $increment Increase current tabindex by this value
* @return string
*/
protected function getTabIndexHTML($increment = 0) {
$tabIndex = (int)$this->getTabIndex() + (int)$increment;
return (is_numeric($tabIndex)) ? ' tabindex = "' . $tabIndex . '"' : '';
}
function dataValue() {
if(is_array($this->value)) return implode("", $this->value);
else return $this->value;

View File

@ -50,13 +50,6 @@ class FormField extends RequestHandler {
*/
protected $leftTitle;
/**
* Set the "tabindex" HTML attribute on the field.
*
* @var int
*/
protected $tabIndex;
/**
* Stores a reference to the FieldList that contains this object.
* @var FieldList
@ -225,30 +218,24 @@ class FormField extends RequestHandler {
* Set tabindex HTML attribute
* (defaults to none).
*
* @deprecated 3.0 Use setAttribute("tabindex") instead
* @param int $index
*/
public function setTabIndex($index) {
$this->tabIndex = $index;
Deprecation::notice('3.0', 'Use setAttribute("tabindex") instead');
$this->setAttribute($index);
return $this;
}
/**
* Get tabindex (if previously set)
*
* @deprecated 3.0 Use getAttribute("tabindex") instead
* @return int
*/
public function getTabIndex() {
return $this->tabIndex;
}
/**
* Get tabindex HTML string
*
* @param int $increment Increase current tabindex by this value
* @return string
*/
protected function getTabIndexHTML($increment = 0) {
$tabIndex = (int)$this->getTabIndex() + (int)$increment;
return (is_numeric($tabIndex)) ? ' tabindex = "' . $tabIndex . '"' : '';
Deprecation::notice('3.0', 'Use getAttribute("tabindex") instead');
return $this->getAttribute('tabindex');
}
/**
@ -301,6 +288,12 @@ class FormField extends RequestHandler {
/**
* Set an HTML attribute on the field element, mostly an <input> tag.
*
* Some attributes are best set through more specialized methods, to avoid interfereing with built-in behaviour:
* - 'class': {@link addExtraClass()}
* - 'title': {@link setDescription()}
* - 'value': {@link setValue}
* - 'name': {@link setName}
*
* CAUTION Doesn't work on most fields which are composed of more than one HTML form field:
* AjaxUniqueTextField, CheckboxSetField, ComplexTableField, CompositeField, ConfirmedPasswordField, CountryDropdownField,
* CreditCardField, CurrencyField, DateField, DatetimeField, FieldGroup, GridField, HtmlEditorField,
@ -335,7 +328,6 @@ class FormField extends RequestHandler {
'value' => $this->Value(),
'class' => $this->extraClass(),
'id' => $this->ID(),
'tabindex' => $this->getTabIndex(),
'disabled' => $this->isDisabled(),
'title' => $this->getDescription(),
);