From 5facb9bceb036e7074e65f767f7fed26f2bd07e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de>
Date: Tue, 27 Mar 2018 13:19:49 +0200
Subject: [PATCH] feat(Form): add method to get position of element by element

---
 inc/Form/Form.php | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/inc/Form/Form.php b/inc/Form/Form.php
index 2d534aee5..91e85d72a 100644
--- a/inc/Form/Form.php
+++ b/inc/Form/Form.php
@@ -78,6 +78,20 @@ class Form extends Element {
         return count($this->elements);
     }
 
+    /**
+     * Get the position of the element in the form or false if it is not in the form
+     *
+     * Warning: This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.
+     *
+     * @param Element $element
+     *
+     * @return false|int
+     */
+    public function getElementPosition(Element $element)
+    {
+        return array_search($element, $this->elements, true);
+    }
+
     /**
      * Returns a reference to the element at a position.
      * A position out-of-bounds will return either the
-- 
GitLab