Permalink
Browse files

ENHANCEMENT: move hard coded template HTML for composite field and fi…

…eld group out to separate template files.
  • Loading branch information...
1 parent 3572b31 commit 907568b1827abcc2f25cd38a2b90a80ac7a7bb66 @wilr wilr committed Apr 13, 2012
@@ -197,7 +197,7 @@ form.small .field input.text, form.small .field textarea, form.small .field sele
.cms .ss-ui-loading-icon { background: url(../../images/network-save.gif) no-repeat; display: block; width: 16px; height: 16px; }
/** ---------------------------------------------------- Grouped form fields ---------------------------------------------------- */
-.fieldgroup .fieldgroup-field { float: left; display: block; width: 184px; padding-right: 8px; }
+.fieldgroup .fieldgroup-field { float: left; display: block; width: 184px; padding: 8px 0 0 8px; }
.fieldgroup .fieldgroup-field .field { border: none; padding-bottom: 0; }
/** ---------------------------------------------------- Checkbox Field ---------------------------------------------------- */
@@ -353,7 +353,7 @@ body.cms { overflow: hidden; }
/* -------------------------------------------------------- Content Tools is the sidebar on the left of the main content panel */
.cms-content-tools { background-color: #dde3e7; width: 192px; border-right: 1px solid #bfcad2; overflow-y: auto; overflow-x: hidden; z-index: 70; -moz-box-shadow: rgba(107, 120, 123, 0.5) 0 0 4px; -webkit-box-shadow: rgba(107, 120, 123, 0.5) 0 0 4px; -o-box-shadow: rgba(107, 120, 123, 0.5) 0 0 4px; box-shadow: rgba(107, 120, 123, 0.5) 0 0 4px; float: left; position: relative; }
.cms-content-tools .cms-panel-header { clear: both; margin: 0 0 7px; line-height: 24px; border-bottom: 1px solid rgba(201, 205, 206, 0.8); -webkit-box-shadow: 0 1px 0 rgba(228, 230, 230, 0.8); -moz-box-shadow: 0 1px 0 rgba(228, 230, 230, 0.8); -o-box-shadow: 0 1px 0 rgba(228, 230, 230, 0.8); box-shadow: 0 1px 0 rgba(228, 230, 230, 0.8); }
-.cms-content-tools .cms-panel-content { width: 176px; padding: 8px 8px; overflow: auto; height: 100%; }
+.cms-content-tools .cms-panel-content { width: 176px; padding: 0 8px; overflow: auto; height: 100%; }
.cms-content-tools .cms-panel-content .dropdown select { width: 160px; }
.cms-content-tools .cms-panel-content #LastEditedFrom { -moz-box-shadow: none; -webkit-box-shadow: none; -o-box-shadow: none; box-shadow: none; }
.cms-content-tools .cms-panel-content #LastEditedFrom input { width: 160px; }
@@ -406,7 +406,7 @@ form.small .field, .field.small {
float: left;
display: block;
width: $grid-x * 23;
- padding-right: $grid-x;
+ padding: $grid-y 0 0 $grid-x;
&.odd {
@@ -610,8 +610,8 @@ body.cms {
}
.cms-panel-content {
- width: $grid-x * 22;
- padding: $grid-y $grid-x;
+ width: ($grid-x * 22);
+ padding: 0 $grid-x;
overflow: auto;
height:100%;
.dropdown select {
View
@@ -8,17 +8,17 @@ table.details tr { background: #eeeee0; }
p { line-height: 1.5em; margin-top: 0.5em; margin-bottom: 1.0em; }
-h1 { margin: 0px 0px 5px; font: 165% verdana, arial, helvetica; }
+h1 { margin: 0px 0px 5px; font: 165% verdana,arial,helvetica; }
-h2 { margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana, arial, helvetica; }
+h2 { margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica; }
-h3 { margin-bottom: 0.5em; font: bold 115% verdana, arial, helvetica; }
+h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica; }
-h4 { margin-bottom: 0.5em; font: bold 100% verdana, arial, helvetica; }
+h4 { margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica; }
-h5 { margin-bottom: 0.5em; font: bold 100% verdana, arial, helvetica; }
+h5 { margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica; }
-h6 { margin-bottom: 0.5em; font: bold 100% verdana, arial, helvetica; }
+h6 { margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica; }
@chillu
chillu Apr 14, 2012 SilverStripe Ltd. member

Ah the good old war between an old and new version of compass ... which one are you running Will?

.Error { font-weight: bold; color: red; }
@@ -228,7 +228,10 @@ function setUp() {
// Preserve memory settings
$this->originalMemoryLimit = ini_get('memory_limit');
-
+
+ // turn off template debugging
+ SSViewer::set_source_file_comments(false);
+
// Clear requirements
Requirements::clear();
}
@@ -34,6 +34,11 @@ 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.
@@ -59,6 +64,8 @@ public function __construct($children = null) {
/**
* Returns all the sub-fields, suitable for <% control FieldList %>
+ *
+ * @return FieldList
*/
public function FieldList() {
return $this->children;
@@ -76,9 +83,10 @@ public function setID($id) {
$this->id = $id;
return $this;
}
-
+
/**
* Accessor method for $this->children
+ *
* @return FieldList
*/
public function getChildren() {
@@ -93,31 +101,41 @@ public function setChildren($children) {
return $this;
}
- /** @param String */
+ /**
+ * @param string
+ */
public function setTag($tag) {
$this->tag = $tag;
+
return $this;
}
- /** @return String */
+ /**
+ * @return string
+ */
public function getTag() {
return $this->tag;
}
- /** @param String */
+ /**
+ * @param string
+ */
public function setLegend($legend) {
$this->legend = $legend;
return $this;
}
- /** @return String */
+ /**
+ * @return string
+ */
public function getLegend() {
return $this->legend;
}
function extraClasses() {
$classes = array('field', 'CompositeField', parent::extraClasses());
if($this->columnCount) $classes[] = 'multicolumn';
+
return implode(' ', $classes);
}
@@ -135,79 +153,35 @@ function getAttributes() {
}
public function Field($properties = array()) {
- $content = '';
-
- if($this->tag == 'fieldset' && $this->legend) {
- $content .= '<legend>' . $this->legend . '<legend>';
- }
-
- $fs = $this->FieldList();
- foreach($fs as $subfield) {
- if($this->columnCount) {
- $className = "column{$this->columnCount}";
- if(!next($fs)) $className .= " lastcolumn";
- $content .= "\n<div class=\"{$className}\">\n" . $subfield->Field() . "\n</div>\n";
- } else if($subfield){
- $content .= "\n" . $subfield->Field() . "\n";
- }
- }
-
- return $this->createTag($this->getTag(), $this->getAttributes(), $content);
+ $props = $this->customise($properties);
+
+ return $props->renderWith($this->getTemplate());
}
/**
- * Returns the fields nested inside another DIV
+ * @param array
*/
function FieldHolder($properties = array()) {
- $content = '';
+ $props = $this->customise($properties);
- if($this->tag == 'fieldset' && $this->legend) {
- $content .= '<legend>' . $this->legend . '<legend>';
- }
-
- $fs = $this->FieldList();
- foreach($fs as $subfield) {
- if($this->columnCount) {
- $className = "column{$this->columnCount}";
- if(!next($fs)) $className .= " lastcolumn";
- $content .= "\n<div class=\"{$className}\">\n" . $subfield->FieldHolder() . "\n</div>\n";
- } else if($subfield){
- $content .= "\n" . $subfield->FieldHolder() . "\n";
- }
- }
-
- return $this->createTag($this->getTag(), $this->getAttributes(), $content);
+ return $props->renderWith($this->getTemplate());
}
/**
- * Returns the fields in the restricted field holder inside a DIV.
+ * Returns the fields in the restricted field holder.
+ *
+ * @param array
*/
- function SmallFieldHolder() {
- $fs = $this->FieldList();
- $tag = $this->getTag();
- $idAtt = isset($this->id) ? " id=\"{$this->id}\"" : '';
- $className = ($this->columnCount) ? "field CompositeField {$this->extraClass()} multicolumn" : "field CompositeField {$this->extraClass()}";
- $content = "<$tag class=\"$className\"$idAtt>";
-
- if($this->tag == 'fieldset' && $this->legend) {
- $content .= '<legend>' . $this->legend . '<legend>';
- }
-
- foreach($fs as $subfield) {
- if($this->columnCount) {
- $className = "column{$this->columnCount}";
- if(!next($fs)) $className .= " lastcolumn";
- $content .= "<div class=\"{$className}\">" . $subfield->FieldHolder() . "</div>";
- } else if($subfield){
- $content .= $subfield->SmallFieldHolder() . " ";
- }
- }
- $content .= "</$tag>";
-
- return $content;
+ 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.
+ * Add all of the non-composite fields contained within this field to the
+ * list.
+ *
* Sequentialisation is used when connecting the form to its data source
*/
public function collateDataFields(&$list, $saveableOnly = false) {
@@ -232,8 +206,11 @@ public function collateDataFields(&$list, $saveableOnly = false) {
}
function setForm($form) {
- foreach($this->children as $f) if(is_object($f)) $f->setForm($form);
+ foreach($this->children as $f)
+ if(is_object($f)) $f->setForm($form);
+
parent::setForm($form);
+
return $this;
}
@@ -242,6 +219,10 @@ function setColumnCount($columnCount) {
return $this;
}
+ function getColumnCount() {
+ return $this->columnCount;
+ }
+
function isComposite() {
return true;
}
@@ -253,8 +234,11 @@ function hasData() {
public function fieldByName($name) {
return $this->children->fieldByName($name);
}
+
/**
* Add a new child field to the end of the set.
+ *
+ * @param FormField
*/
public function push(FormField $field) {
$this->children->push($field);
Oops, something went wrong.

0 comments on commit 907568b

Please sign in to comment.