Copy-paste fix for elements with max_length set.

Copy-paste wasn't working with elements which had a max length set, that's fixed with this commit.