Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

API CHANGE Deprecated FormField->getTabIndex()/setTabIndex(), use get…

…Attribute()/setAttribute() instead. Removed FormField->getTabIndexHTML()
  • Loading branch information...
commit 391ffde4f3e0f75407b51bb82a0a6b48babbbfb0 1 parent 9a96b92
@chillu chillu authored
View
2  forms/ConfirmedPasswordField.php
@@ -113,7 +113,7 @@ function Field() {
}
$content .= "<div class=\"showOnClick\">\n";
- $content .= "<a href=\"#\"" . $this->getTabIndexHTML() . ">{$title}</a>\n";
+ $content .= "<a href=\"#\">{$title}</a>\n";
$content .= "<div class=\"showOnClickContainer\">";
}
View
11 forms/CreditCardField.php
@@ -18,6 +18,17 @@ function Field() {
"<input autocomplete=\"off\" name=\"{$this->name}[3]\" value=\"$parts[3]\" maxlength=\"4\"" . $this->getTabIndexHTML(3) . " /></span>";
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);
View
34 forms/FormField.php
@@ -51,13 +51,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,33 +218,27 @@ function setLeftTitle($val) {
* 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;
+ Deprecation::notice('3.0', 'Use getAttribute("tabindex") instead');
+ return $this->getAttribute('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 . '"' : '';
- }
-
- /**
* Compiles all CSS-classes. Optionally includes a "nolabel"-class
* if no title was set on the formfield.
* Uses {@link Message()} and {@link MessageType()} to add validatoin
@@ -301,6 +288,12 @@ function removeExtraClass($class) {
/**
* 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 @@ function getAttributes() {
'value' => $this->Value(),
'class' => $this->extraClass(),
'id' => $this->ID(),
- 'tabindex' => $this->getTabIndex(),
'disabled' => $this->isDisabled(),
'title' => $this->getDescription(),
);
Please sign in to comment.
Something went wrong with that request. Please try again.