summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/html/src/Contract/FormElementDecorator.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ipl/html/src/Contract/FormElementDecorator.php')
-rw-r--r--vendor/ipl/html/src/Contract/FormElementDecorator.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/ipl/html/src/Contract/FormElementDecorator.php b/vendor/ipl/html/src/Contract/FormElementDecorator.php
new file mode 100644
index 0000000..ca770ea
--- /dev/null
+++ b/vendor/ipl/html/src/Contract/FormElementDecorator.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace ipl\Html\Contract;
+
+use ipl\Html\ValidHtml;
+
+/**
+ * Representation of form element decorators
+ */
+interface FormElementDecorator extends ValidHtml
+{
+ /**
+ * Decorate the given form element
+ *
+ * Decoration works by calling `prependWrapper()` on the form element,
+ * passing a clone of the decorator. Hidden elements are to be ignored.
+ *
+ * **Reference implementation:**
+ *
+ * ```php
+ * public function decorate(FormElement $formElement)
+ * {
+ * if ($formElement instanceof HiddenElement) {
+ * return;
+ * }
+ *
+ * $decorator = clone $this;
+ *
+ * // Wrapper logic can be overridden to adjust or propagate the decorator.
+ * // So here we make sure that a yet unbound decorator is passed.
+ * $formElement->prependWrapper($decorator);
+ *
+ * ...
+ * }
+ * ```
+ *
+ * @param FormElement $formElement
+ */
+ public function decorate(FormElement $formElement);
+}