n:name and n:attr synergy

5 years ago

duke
Member | 646
+
0
-

In current master, if you use e.g.:

<select n:name="foo" n:attr="id => $id"></select>

… it will render the id attribute twice when $id is not NULL. Expected behavior would be n:attr settings overriding the input's original attributes thus rendering them only once.

5 years ago

Jan Tvrdík
Nette guru | 2556
+
0
-

That's unlikely to ever work.

5 years ago

Aurielle
Member | 1283
+
0
-

Overriding form element's ID is kinda dangerous in regards to client-side validation and such practice should be approached with caution.

5 years ago

David Grudl
Nette Core | 6850
+
0
-

n:attr should be fixed to not create duplicated attributes here https://github.com/…reMacros.php#L294 using ->addAttributes(%var) & array_fill_keys(array_keys($node->htmlNode->attrs), NULL), exactly as here https://github.com/…rmMacros.php#L164.

Fixing combination of n:name & n:attr requires to change $node->htmlNode->attrs