Add support for non-form elements and support per-element configuration settings 

Resubmit of #4813 after rebase from upstream.