-
-
Notifications
You must be signed in to change notification settings - Fork 212
addAttributes
method is confusing in Widget class
#7095
Comments
What would you suggest? |
I think we could safely use |
This can never be the solution! |
Another solution. Add new method And in public function addConfigurations($arrConfigurations)
{
if (!is_array($arrConfigurations))
{
return;
}
foreach ($arrConfigurations as $k=>$v)
{
$this->$k = $v;
}
}
public function addAttributes($arrAttributes)
{
if (!is_array($arrAttributes))
{
return;
}
if (version_compare(VERSION, '3.3', '<') && version_compare(BUILD, '3', '<'))
{
$this->addConfigurations($arrAttributes);
}
else
{
foreach ($arrAttributes as $k=>$v)
{
$this->addAttribute($k, $v);
}
}
} |
The best solution IMHO is to adjust the |
But HTML 5 specification allows to add attribute with any name not only with |
For example, AngularJS uses custom HTML attributes like |
Then we need to discuss this. @contao/developers |
|
Yep, AngularJS is not valid by default - you have to use a directive to validate it. |
Whats the problem with invalid attributes? Imho are there no side effects and are heavily used by various JS widgets like Angular or Datepickers. For me we sould accept every attribute a developer pushes in! |
I don't have any problems with invalid attributes. |
Please read the ticket – you are missing the point. |
Changed in b6f5d08. I have added support for |
Widget
class has two methods for adding attributes:addAttribute
andaddAttributes
.addAttribute
method is working fine and it allows to add custom attributes to widget.and it will generate widget with this attributes:
But,
addAttributes
doesn't work as expected.In this case no attributes will be generated
The problem is in that
addAttributes
methods invokes__set
magick method and add unknowns attributes to$arrConfiguration
value.addAttribute
method directly adds attributes to protected$arrAttributes
value. AndgetAttributes
method takes attributes from$arrAttributes
value not$arrConfiguration
.The text was updated successfully, but these errors were encountered: