Support for required

Both v3 and v4 variant of json schema or as override on the form.
Also reduced template duplication.