mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merged revisions 47499 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r47499 | ischommer | 2007-12-22 17:23:26 +1300 (Sat, 22 Dec 2007) | 1 line added tabIndex ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52187 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2f51144a85
commit
aa13b78838
@ -41,6 +41,13 @@ class FormField extends ViewableData {
|
||||
*/
|
||||
protected $leftTitle;
|
||||
|
||||
/**
|
||||
* Set the "tabindex" HTML attribute on the field.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $tabIndex;
|
||||
|
||||
/**
|
||||
* Create a new field.
|
||||
* @param name The internal field name, passed to forms.
|
||||
@ -77,6 +84,9 @@ class FormField extends ViewableData {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function attrName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field message, used by form validation
|
||||
@ -143,6 +153,36 @@ class FormField extends ViewableData {
|
||||
$this->leftTitle = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tabindex HTML attribute
|
||||
* (defaults to none).
|
||||
*
|
||||
* @param int $index
|
||||
*/
|
||||
public function setTabIndex($index) {
|
||||
$this->tabIndex = $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tabindex (if previously set)
|
||||
*
|
||||
* @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 . '"' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles all CSS-classes. Optionally includes a "nolabel"-class
|
||||
* if no title was set on the formfield.
|
||||
@ -242,7 +282,7 @@ class FormField extends ViewableData {
|
||||
if($this->value) $val = $this->dontEscape ? ($this->reserveNL?Convert::raw2xml($this->value):$this->value) : Convert::raw2xml($this->value);
|
||||
else $val = '<i>('._t('FormField.NONE', 'none').')</i>';
|
||||
$valforInput = $this->value ? Convert::raw2att($val) : "";
|
||||
return "<span class=\"readonly\" id=\"" . $this->id() . "\">$val</span>\n<input type=\"hidden\" name=\"".$this->name."\" value=\"".$valforInput."\" />";
|
||||
return "<span class=\"readonly\" id=\"" . $this->id() . "\">$val</span>\n<input type=\"hidden\" name=\"".$this->name."\" value=\"".$valforInput."\"" . $this->getTabIndexHTML() . " />";
|
||||
}
|
||||
/**
|
||||
* Returns a "Field Holder" for this field - used by templates.
|
||||
|
Loading…
x
Reference in New Issue
Block a user