Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 2ad2557

Browse files
committed
Adds documentation of new methods introduced in #194
1 parent 1b75b19 commit 2ad2557

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/book/helper/abstract-helper.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Method signature | Description
2525
`addTranslatableAttributePrefix(string $prefix) : self` | Marks all HTML attributes that start with the given prefix as translatable.
2626
`addDefaultTranslatableAttribute(string $attribute) : void` | Marks the given HTML attribute as translatable for all view helpers.
2727
`addDefaultTranslatableAttributePrefix(string $prefix) : void` | Marks all HTML attributes that start with the given prefix as translatable for all view helpers.
28+
`addValidAttribute(string $attribute) : self` | Add an HTML attribute to the list of valid attributes for the given element.
29+
`addValidAttributePrefix(string $prefix) : self` | Add an HTML attribute prefix to the list of valid attribute prefixes. Any attribute with this preix will be considered valid. By default, the list includes "data-", "aria-", and "x-".
2830

2931
## Translation
3032

@@ -69,3 +71,27 @@ Or you can mark them as translatable for all view helpers (e. g. the title attri
6971
// mark an prefix as translatable
7072
\Zend\Form\View\Helper\AbstractHelper->addDefaultTranslatableAttributePrefix('data-translatable-');
7173
```
74+
75+
## Allowing framework-specific attributes
76+
77+
Many JavaScript frameworks use custom attributes and/or attribute prefixes with
78+
elements, to facilitate various bindings and event listeners. Examples include
79+
`ng-` for [Angular](https://angularjs.org) elements, and `v-` for
80+
[Vue](https://vuejs.org).
81+
82+
zend-form view helpers are strict about what attributes they consider valid. If
83+
you wish to allow additional attributes, you will need to notify the helper of
84+
them.
85+
86+
The first mechanism is to add a specific attribute:
87+
88+
```php
89+
$helper->addValidAttribute('some-attribute');
90+
```
91+
92+
If you wish to allow a set of attributes with a common prefix, use the
93+
following:
94+
95+
```php
96+
$helper->addValidAttributePrefix('ng-');
97+
```

0 commit comments

Comments
 (0)