n:name and n:attr synergy

Notice: This thread is very old.
duke
Member | 650
+
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.

Jan Tvrdík
Nette guru | 2595
+
0
-

That's unlikely to ever work.

Aurielle
Member | 1281
+
0
-

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

David Grudl
Nette Core | 8107
+
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