summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/html/src/Contract/FormElementDecorator.php
blob: ca770eaa5bb65f224d2a6cb6ce85a46500ef4812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);
}