MINOR function php doc comments, and code formatting

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@56141 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-06-12 08:54:03 +00:00
parent f5987f7473
commit f2bfbc652e

View File

@ -157,7 +157,7 @@ class FieldSet extends DataObjectSet {
} }
/** /**
* Returns the named field. * Returns a named field.
* *
* @todo Implement similiarly to dataFieldByName() to support nested sets - or merge with dataFields() * @todo Implement similiarly to dataFieldByName() to support nested sets - or merge with dataFields()
*/ */
@ -168,8 +168,11 @@ class FieldSet extends DataObjectSet {
} }
/** /**
* Returns the named field in a sequential set. * Returns a named field in a sequential set.
* use this if your using nested formfields. * Use this if you're using nested FormFields.
*
* @param string $name The name of the field to return
* @return FormField instance
*/ */
public function dataFieldByName($name) { public function dataFieldByName($name) {
if($dataFields = $this->dataFields()) { if($dataFields = $this->dataFields()) {
@ -179,24 +182,27 @@ class FieldSet extends DataObjectSet {
} }
} }
/**
* Inserts a field before a particular field in a FieldSet.
*
* @param FormField $item The form field to insert
* @param string $name Name of the field to insert before
*/
public function insertBefore($item, $name) { public function insertBefore($item, $name) {
if($this->sequentialSet) $this->sequentialSet = null; if($this->sequentialSet) $this->sequentialSet = null;
$i = 0; $i = 0;
foreach($this->items as $child) { foreach($this->items as $child) {
if($name == $child->Name() || $name == $child->id) { if($name == $child->Name() || $name == $child->id) {
array_splice($this->items, $i, 0, array($item)); array_splice($this->items, $i, 0, array($item));
return; return;
} }
$i++; $i++;
} }
$this->items[] = $item; $this->items[] = $item;
} }
/** /**
* Inserts an item before the item with name $name * Inserts an item before the item with name $name
* It can be buried in a composite field * It can be buried in a composite field
@ -227,28 +233,42 @@ class FieldSet extends DataObjectSet {
return false; return false;
} }
/**
* Inserts a field after a particular field in a FieldSet.
*
* @param FormField $item The form field to insert
* @param string $name Name of the field to insert after
*/
public function insertAfter($item, $name) { public function insertAfter($item, $name) {
if($this->sequentialSet) $this->sequentialSet = null; if($this->sequentialSet) $this->sequentialSet = null;
$i = 0; $i = 0;
foreach($this->items as $child) { foreach($this->items as $child) {
if($name == $child->Name() || $name == $child->id) { if($name == $child->Name() || $name == $child->id) {
array_splice($this->items, $i + 1, 0, array($item)); array_splice($this->items, $i + 1, 0, array($item));
return; return;
} }
$i++; $i++;
} }
$this->items[] = $item; $this->items[] = $item;
} }
/**
* Push a single field into this FieldSet instance.
*
* @param FormField $item The FormField to add
* @param string $key An option array key (field name)
*/
public function push($item, $key = null) { public function push($item, $key = null) {
if($this->sequentialSet) $this->sequentialSet = null; if($this->sequentialSet) $this->sequentialSet = null;
return parent::push($item, $key = null); return parent::push($item, $key = null);
} }
/**
* Set the Form instance for this FieldSet.
*
* @param Form $form
*/
public function setForm($form) { public function setForm($form) {
foreach($this as $field) $field->setForm($form); foreach($this as $field) $field->setForm($form);
} }
@ -283,7 +303,10 @@ class FieldSet extends DataObjectSet {
} }
/** /**
* Convert this form into a readonly form * Transform this FieldSet with a given tranform method,
* e.g. $this->transform(new ReadonlyTransformation())
*
* @return FieldSet
*/ */
function transform($trans) { function transform($trans) {
$this->sequentialSet = null; $this->sequentialSet = null;
@ -294,6 +317,11 @@ class FieldSet extends DataObjectSet {
return $newFields; return $newFields;
} }
/**
* Transforms this FieldSet instance to readonly.
*
* @return FieldSet
*/
function makeReadonly() { function makeReadonly() {
return $this->transform(new ReadonlyTransformation()); return $this->transform(new ReadonlyTransformation());
} }