Skip to content

Commit bc28d5f

Browse files
authored
id attribute support added for csrf_field
i.e. useful in autocomplete forms (it is faster to reach this field by id than by name or its position in form)
1 parent 1680e90 commit bc28d5f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

system/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,9 @@ function csrf_hash()
688688
*
689689
* @return string
690690
*/
691-
function csrf_field()
691+
function csrf_field(string $id = null)
692692
{
693-
return '<input type="hidden" name="' . csrf_token() . '" value="' . csrf_hash() . '">';
693+
return '<input type="hidden"' . (!empty($id) ? ' id="' . esc($id, 'attr') . '"' : '') . ' name="' . csrf_token() . '" value="' . csrf_hash() . '">';
694694
}
695695
}
696696

0 commit comments

Comments
 (0)