From a6148c33da3e69be3cf316468ddde3b4047d941d Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 21 Dec 2011 17:35:42 +0100 Subject: [PATCH] MERGE Using FormField->template in most fields --- forms/CheckboxField.php | 11 ++++------- forms/CheckboxSetField.php | 6 +++--- forms/CreditCardField.php | 1 + forms/CurrencyField.php | 1 + forms/DropdownField.php | 9 +++------ forms/EmailField.php | 6 +----- forms/FileField.php | 4 +++- forms/FormAction.php | 4 +++- forms/FormField.php | 28 +++++++++++++++++++++------- forms/HeaderField.php | 6 ++---- forms/HiddenField.php | 4 +--- forms/ImageFormAction.php | 5 ++--- forms/LabelField.php | 9 ++------- forms/OptionsetField.php | 4 +++- forms/PasswordField.php | 16 +++------------- forms/TextField.php | 4 +++- forms/TextareaField.php | 4 +++- 17 files changed, 59 insertions(+), 63 deletions(-) diff --git a/forms/CheckboxField.php b/forms/CheckboxField.php index f99d6b941..b8e12e036 100644 --- a/forms/CheckboxField.php +++ b/forms/CheckboxField.php @@ -6,6 +6,10 @@ */ class CheckboxField extends FormField { + protected $template = 'CheckboxField'; + + protected $fieldHolderTemplate = 'CheckboxFieldHolder'; + function setValue($value) { $this->value = ($value) ? 1 : 0; } @@ -18,13 +22,6 @@ class CheckboxField extends FormField { return ($this->value) ? 1 : 0; } - function Field($properties = array()) { - return $this->customise($properties)->renderWith('CheckboxField'); - } - - function FieldHolder() { - $this->setFieldHolderTemplate(($this->fieldHolderTemplate) ? $this->fieldHolderTemplate : 'CheckboxFieldHolder'); - return parent::FieldHolder(); } /** diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index b982cc746..378534377 100644 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -33,8 +33,8 @@ * @subpackage fields-basic */ class CheckboxSetField extends OptionsetField { - - protected $disabled = false; + + protected $template = 'CheckboxSetField'; /** * @var Array @@ -133,7 +133,7 @@ class CheckboxSetField extends OptionsetField { $properties = array_merge($properties, array('Options' => new ArrayList($options))); - return $this->customise($properties)->renderWith('CheckboxSetField'); + return $this->customise($properties)->renderWith($this->getTemplate()); } function setDisabled($val) { diff --git a/forms/CreditCardField.php b/forms/CreditCardField.php index 0b41f400b..b6c7156f9 100644 --- a/forms/CreditCardField.php +++ b/forms/CreditCardField.php @@ -16,6 +16,7 @@ class CreditCardField extends TextField { "name}[3]\" value=\"$parts[3]\" maxlength=\"4\"" . $this->getTabIndexHTML(3) . " />"; return $field; } + function dataValue() { if(is_array($this->value)) return implode("", $this->value); else return $this->value; diff --git a/forms/CurrencyField.php b/forms/CurrencyField.php index afd893385..1edfe03ce 100644 --- a/forms/CurrencyField.php +++ b/forms/CurrencyField.php @@ -103,6 +103,7 @@ class CurrencyField_Readonly extends ReadonlyField{ $valforInput = $this->value ? Convert::raw2att($val) : ""; return "extraClass()."\" id=\"" . $this->id() . "\">$valname."\" value=\"".$valforInput."\" />"; } + /** * This already is a readonly field. */ diff --git a/forms/DropdownField.php b/forms/DropdownField.php index 839bca967..fe06042d1 100644 --- a/forms/DropdownField.php +++ b/forms/DropdownField.php @@ -77,6 +77,8 @@ */ class DropdownField extends FormField { + protected $template = 'DropdownField'; + /** * @var boolean $source Associative or numeric array of all dropdown items, * with array key as the submitted field value, and the array value as a @@ -91,11 +93,6 @@ class DropdownField extends FormField { */ protected $isSelected; - /** - * @var boolean $disabled - */ - protected $disabled; - /** * @var boolean $hasEmptyDefault Show the first