Permalink
Browse files

ENHANCEMENT: populate FormField:: on the fly based on class name of f…

…ield rather than requiring explict definition.
  • Loading branch information...
1 parent 907568b commit 07d2d5273ac890e9a5ea81a4bf83b5ef001e3bb6 @wilr wilr committed Apr 14, 2012
View
@@ -65,10 +65,10 @@
.cms table.ss-gridfield-table tr th button.ss-gridfield-sort:hover { background-position: right -34px; }
.cms table.ss-gridfield-table tr th button.ss-gridfield-sort.ss-gridfield-sorted-desc { background-position: right -72px; }
.cms table.ss-gridfield-table tr th button.ss-gridfield-sort.ss-gridfield-sorted-asc { background-position: right -116px; }
-.cms table.ss-gridfield-table tr th button.ss-gridfield-button-filter.ss-ui-button { position: absolute; right: 5px; top: -28px; display: block; text-indent: -9999em; width: 30px; height: 28px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-width: 1px; border-color: #9a9a9a; background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #d9d9d9)); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -webkit-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -moz-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -o-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -ms-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, linear-gradient(#ffffff, #d9d9d9); }
+.cms table.ss-gridfield-table tr th button.ss-gridfield-button-filter.ss-ui-button { position: absolute; top: 0; right: 0; display: block; text-indent: -9999em; width: 30px; height: 28px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-width: 1px; border-color: #9a9a9a; background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #d9d9d9)); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -webkit-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -moz-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -o-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, -ms-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat -40px 6px, linear-gradient(#ffffff, #d9d9d9); }
.cms table.ss-gridfield-table tr th button.ss-gridfield-button-filter.ss-ui-button.hover-alike:active { background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #4199cd), color-stop(100%, #2e7ead)); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -webkit-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -moz-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -o-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -ms-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, linear-gradient(#4199cd, #2e7ead); -moz-box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); -webkit-box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); -o-box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); }
.cms table.ss-gridfield-table tr th button.ss-gridfield-button-filter.ss-ui-button.hover-alike { background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #4199cd), color-stop(100%, #2e7ead)); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -webkit-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -moz-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -o-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, -ms-linear-gradient(#4199cd, #2e7ead); background: url(../images/icons/filter-icons.png) no-repeat -16px 6px, linear-gradient(#4199cd, #2e7ead); }
-.cms table.ss-gridfield-table tr th button.ss-gridfield-button-reset.ss-ui-button { position: absolute; right: 34px; top: -28px; display: block; text-indent: -9999em; width: 30px; height: 28px; float: right; border-radius: 0px; border-bottom-width: 1px; border-color: #9a9a9a; background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #d9d9d9)); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -webkit-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -moz-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -o-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -ms-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, linear-gradient(#ffffff, #d9d9d9); }
+.cms table.ss-gridfield-table tr th button.ss-gridfield-button-reset.ss-ui-button { position: absolute; right: 29px; top: 0; display: block; text-indent: -9999em; width: 30px; height: 28px; float: right; border-radius: 0px; border-bottom-width: 1px; border-color: #9a9a9a; background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #d9d9d9)); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -webkit-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -moz-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -o-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, -ms-linear-gradient(#ffffff, #d9d9d9); background: url(../images/icons/filter-icons.png) no-repeat 8px 5px, linear-gradient(#ffffff, #d9d9d9); }
.cms table.ss-gridfield-table tr th button.ss-gridfield-button-reset.ss-ui-button.filtered:hover { background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ff0000), color-stop(100%, #cc0000)); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -webkit-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -moz-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -o-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -ms-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, linear-gradient(#ff0000, #cc0000); }
.cms table.ss-gridfield-table tr th button.ss-gridfield-button-reset.ss-ui-button.filtered:active { background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ff0000), color-stop(100%, #cc0000)); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -webkit-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -moz-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -o-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, -ms-linear-gradient(#ff0000, #cc0000); background: url(../images/icons/filter-icons.png) no-repeat 8px -17px, linear-gradient(#ff0000, #cc0000); -moz-box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); -webkit-box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); -o-box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); box-shadow: inset 0 1px 3px #17181a, 0 1px 0 rgba(255, 255, 255, 0.6); }
.cms table.ss-gridfield-table tr th input.ss-gridfield-sort { padding: 2px; }
@@ -1,15 +1,12 @@
<?php
/**
* Single checkbox field.
+ *
* @package forms
* @subpackage fields-basic
*/
class CheckboxField extends FormField {
- protected $template = 'CheckboxField';
-
- protected $fieldHolderTemplate = 'CheckboxFieldHolder';
-
function setValue($value) {
$this->value = ($value) ? 1 : 0;
return $this;
@@ -23,17 +20,6 @@ function Value() {
return ($this->value) ? 1 : 0;
}
- /**
- * Returns a restricted field holder used within things like FieldGroups
- */
- function SmallFieldHolder() {
- $result = $this->Field();
- if($t = $this->Title()) {
- $result .= "<label for=\"" . $this->id() ."\">$t</label> ";
- }
- return $result;
- }
-
function getAttributes() {
$attrs = parent::getAttributes();
$attrs['value'] = 1;
@@ -65,6 +51,7 @@ function performDisabledTransformation() {
/**
* Readonly version of a checkbox field - "Yes" or "No".
+ *
* @package forms
* @subpackage fields-basic
*/
@@ -33,11 +33,9 @@
* @subpackage fields-basic
*/
class CheckboxSetField extends OptionsetField {
-
- protected $template = 'CheckboxSetField';
/**
- * @var Array
+ * @var array
*/
protected $defaultItems = array();
@@ -130,7 +128,7 @@ function Field($properties = array()) {
$properties = array_merge($properties, array('Options' => new ArrayList($options)));
- return $this->customise($properties)->renderWith($this->getTemplate());
+ return $this->customise($properties)->renderWith($this->getTemplates());
}
/**
@@ -288,5 +286,4 @@ function Type() {
function ExtraOptions() {
return FormField::ExtraOptions();
}
-
}
@@ -1,8 +1,11 @@
<?php
/**
* Base class for all fields that contain other fields.
- * Implements sequentialisation - so that when we're saving / loading data, we can populate
- * a tabbed form properly. All of the children are stored in $this->children
+ *
+ * Implements sequentialisation - so that when we're saving / loading data, we
+ * can populate a tabbed form properly. All of the children are stored in
+ * $this->children
+ *
* @package forms
* @subpackage fields-structural
*/
@@ -34,11 +37,6 @@ class CompositeField extends FormField {
protected $tag = 'div';
/**
- * @var string
- */
- protected $template = "CompositeField";
-
- /**
* @var String Optional description for this set of fields.
* If the {@link $tag} property is set to use a 'fieldset', this will be
* rendered as a <legend> tag, otherwise its a 'title' attribute.
@@ -152,32 +150,6 @@ function getAttributes() {
);
}
- public function Field($properties = array()) {
- $props = $this->customise($properties);
-
- return $props->renderWith($this->getTemplate());
- }
-
- /**
- * @param array
- */
- function FieldHolder($properties = array()) {
- $props = $this->customise($properties);
-
- return $props->renderWith($this->getTemplate());
- }
-
- /**
- * Returns the fields in the restricted field holder.
- *
- * @param array
- */
- function SmallFieldHolder($properties = array()) {
- $obj = ($properties) ? $this->customise($properties) : $this;
-
- return $obj->renderWith($this->getTemplate());
- }
-
/**
* Add all of the non-composite fields contained within this field to the
* list.
@@ -75,8 +75,6 @@
* @subpackage fields-basic
*/
class DropdownField extends FormField {
-
- protected $template = 'DropdownField';
/**
* @var boolean $source Associative or numeric array of all dropdown items,
@@ -158,7 +156,7 @@ function Field($properties = array()) {
$properties = array_merge($properties, array('Options' => new ArrayList($options)));
- return $this->customise($properties)->renderWith($this->getTemplate());
+ return parent::Field($properties);
}
function getAttributes() {
View
@@ -85,29 +85,6 @@ function Name(){
return preg_replace("/[^a-zA-Z0-9]+/", "", $this->title);
}
-
- /**
- * Generates the field HTML with the HTML for child {@link FormField}
- *
- * @param array $properties custom properties for the template
- */
- function Field($properties = array()) {
- $props = $this->customise(new ArrayData($properties));
-
- return $props->renderWith('FieldGroupField');
- }
-
- /**
- * Generates the field HTML with the HTML for child {@link FormField}
- *
- * @param array $properties custom properties for the template
- */
- function FieldHolder($properties = array()) {
- $props = $this->customise(new ArrayData($properties));
-
- return $props->renderWith('FieldGroupHolder');
- }
-
/**
* Set an odd/even class
*
View
@@ -42,8 +42,6 @@
* @subpackage fields-files
*/
class FileField extends FormField {
-
- protected $template = 'FileField';
/**
* Restrict filesize for either all filetypes
@@ -112,8 +110,11 @@ function __construct($name, $title = null, $value = null) {
}
public function Field($properties = array()) {
- $properties = array_merge($properties, array('MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize()));
- return $this->customise($properties)->renderWith($this->getTemplate());
+ $properties = array_merge($properties, array(
+ 'MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize()
+ ));
+
+ return parent::Field($properties);
}
function getAttributes() {
@@ -12,8 +12,6 @@
*/
class FileIFrameField extends FileField {
- protected $template = 'FileIFrameField';
-
public static $allowed_actions = array (
'iframe',
'EditFileForm',
@@ -20,8 +20,6 @@
*/
class FormAction extends FormField {
- protected $template = 'FormAction';
-
protected $action;
/**
@@ -36,12 +34,14 @@ class FormAction extends FormField {
/**
* Create a new action button.
+ *
* @param action The method to call when the button is clicked
* @param title The label on the button
* @param form The parent form, auto-set when the field is placed inside a form
*/
function __construct($action, $title = "", $form = null) {
$this->action = "action_$action";
+
parent::__construct($this->action, $title, null, $form);
}
@@ -67,7 +67,8 @@ function Field($properties = array()) {
'UseButtonTag' => $this->useButtonTag
)
);
- return $this->customise($properties)->renderWith($this->getTemplate());
+
+ return parent::Field($properties);
}
function FieldHolder($properties = array()) {
Oops, something went wrong. Retry.

0 comments on commit 07d2d52

Please sign in to comment.