Skip to content

Commit 5699f3f

Browse files
committed
Improve readme
1 parent e1cb016 commit 5699f3f

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

README.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,13 @@ Instead of defining an array with values, you can also use a callable to manipul
212212

213213
### Advanced Example: Setting Template Classes at Runtime
214214

215-
Sometimes you need to add attributes to nested template elements, not just the main element. This plugin supports a special syntax to target specific templates within a helper's rendering process.
215+
Sometimes you need to add attributes to parent template elements, not just the element where attributes are applied to (like Form::control). This plugin supports a special syntax to target specific templates within a helper's rendering process.
216+
217+
> [!IMPORTANT]
218+
> This method only works on templates where the attribute is set on the element being rendered. For instance: the attribute is set on the input element, which is part of the inputContainer template. This works.
219+
> For instance: Setting `label:class="class"` on form->control will not work because the input control where this attribute was set on is not rendered inside the label template. You can therefore only target template names that have the available attribute inside.
220+
221+
That said, a handy use case is controlling the wrapper attributes of Form->control:
216222

217223
**Example: Adding classes to the input container**
218224

@@ -246,27 +252,6 @@ Which renders:
246252
</div>
247253
```
248254

249-
**Multiple template targeting:**
250-
251-
You can target multiple templates in a single call:
252-
253-
```php
254-
<?= $this->Form->control('field', [
255-
'class' => 'field-input',
256-
'inputContainer:class' => 'container-style',
257-
'label:class' => 'label-style'
258-
]); ?>
259-
```
260-
261-
Which renders:
262-
263-
```html
264-
<div class="input text container-style">
265-
<label for="field" class="label-style">Field</label>
266-
<input type="text" name="field" class="field-input" id="field" />
267-
</div>
268-
```
269-
270255
**Syntax:**
271256

272257
Use the format `template-name:attributeName` where:

0 commit comments

Comments
 (0)