-
Notifications
You must be signed in to change notification settings - Fork 87
Allow additions to view helper valid attributes #194
Allow additions to view helper valid attributes #194
Conversation
Your commit includes something more: /**
* Attribute prefixes valid for all tags
*
* @var array
*/
protected $validTagAttributePrefixes = [
'data-' => true,
'aria-' => true,
'x-' => true,
]; /**
* Adds a prefix to the list of valid attribute prefixes
*
* @param string $prefix
*
* @return AbstractHelper
*/
public function addValidAttributePrefix($prefix)
{
$this->validTagAttributePrefixes[$prefix] = true;
return $this;
} Please don't mix different topics in one commit. That would help a lot! |
src/View/Helper/AbstractHelper.php
Outdated
*/ | ||
public function addValidAttribute($attribute) | ||
{ | ||
$this->validTagAttributes[$attribute] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No validation of the given parameter?
src/View/Helper/AbstractHelper.php
Outdated
*/ | ||
public function addValidAttributePrefix($prefix) | ||
{ | ||
$this->validTagAttributePrefixes[$prefix] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No validation of the given parameter? (This should be an extra commit.)
@@ -60,6 +60,26 @@ public function testWillNotEncodeValueAttributeValuesCorrectly() | |||
); | |||
} | |||
|
|||
public function testWillIncludeAdditionalAttributes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test covers only the optimal case. The problematic data types are not tested. (see my comments above)
); | ||
} | ||
|
||
public function testWillIncludeAdditionalAttributesByPrefix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. (This should be an extra commit.)
For the moment I added the label "work in progress". I have to look for side effects. |
Related to #50 |
Apologies for the mixed initial commit, I'll try and be more careful in future. Validation and non-optimal test cases have been added. |
Allow additions to view helper valid attributes Conflicts: src/View/Helper/AbstractHelper.php
- Updates docblocks of changed files to match new standards. - Updates docblocks of new properties, methods to match formatting of others. Adds `@throws` annotations to methods throwing exceptions. - Adds labels to each datum in a data provider.
Thanks, @Brindster! |
Currently, the list of valid attributes on the form view helpers is fixed. This pull request adds the ability to add additional valid attributes to view helpers.
My use case is that certain javascript frameworks use non standard attributes (such as
ng-
,v-
) when binding on form elements. It would simplify development ifZend/Form
were able to specify these attributes on form inputs.