Code Duplication    Length = 11-12 lines in 2 locations

forms/CompositeField.php 1 location

@@ 334-345 (lines=12) @@
331
	 * @return int Position in children collection (first position starts with 0). Returns FALSE if the field can't
332
	 *             be found.
333
	 */
334
	public function fieldPosition($field) {
335
		if(is_string($field)) $field = $this->fieldByName($field);
336
		if(!$field) return false;
337
338
		$i = 0;
339
		foreach($this->children as $child) {
340
			if($child->getName() == $field->getName()) return $i;
341
			$i++;
342
		}
343
344
		return false;
345
	}
346
347
	/**
348
	 * Transform the named field into a readonly feld.

forms/FieldList.php 1 location

@@ 606-616 (lines=11) @@
603
	 * @return int Position in children collection (first position starts with 0). Returns FALSE if the field can't
604
	 *             be found.
605
	 */
606
	public function fieldPosition($field) {
607
		if(is_object($field)) $field = $field->getName();
608
609
		$i = 0;
610
		foreach($this->dataFields() as $child) {
611
			if($child->getName() == $field) return $i;
612
			$i++;
613
		}
614
615
		return false;
616
	}
617
618
	/**
619
	 * Ordered list of regular expressions