@@ -55,7 +55,7 @@ As you can see in the example above, the `class` is added twice. This is of cour
5555
5656## Usage
5757
58- ### 1. Configure the Helper
58+ ### Configure the Helper
5959
6060In your ` AppView.php ` , specify the custom template class for any helper you want to use with default attributes:
6161
@@ -69,7 +69,7 @@ $this->loadHelper('Form', [
6969]);
7070```
7171
72- ### 2. Define Templates with defaults
72+ ### Define Templates with defaults
7373
7474Add default attributes to your templates. For example, to set a default class and a custom data attribute for all input fields:
7575
@@ -100,7 +100,7 @@ Renders to
100100<input type =" text" name =" field" class =" defaultClass" data-star =" wars" />
101101```
102102
103- ### 3. Merging default and runtime values
103+ ### Merging default and runtime values
104104
105105If you want to merge default values with those provided at runtime (e.g., for classes), use an array for the default value:
106106
@@ -127,7 +127,26 @@ Renders to
127127<input type =" text" name =" field" class =" firstClass secondClass thirdClass" />
128128```
129129
130- ### 4. Advanced Example: Multiple Attributes
130+ #### Removing default values at runtime
131+
132+ There may be situations where you want to remove the default values. In that case, you can pass ` false ` as the attribute value, and the attribute will then be removed from the element.
133+
134+ Remove entire attribute:
135+
136+ ``` php
137+ <?= $this->Form->control('field', ['class' => 'false']); ?>
138+ // <input type =" text" name =" field" />
139+ ```
140+
141+ You can also bypass default values and only add runtime values:
142+
143+ ``` php
144+ <?= $this->Form->control('field', ['class' => '!!there-can-be-only-one']); ?>
145+ // <input type =" text" name =" field" class =" there-can-be-only-one" />
146+ ```
147+
148+
149+ ### Advanced Example: Multiple Attributes
131150
132151You can set defaults for any attribute, including data attributes and ARIA properties:
133152
0 commit comments