dkan
dkan copied to clipboard
Create special form widget for vCard email field
DCAT-AP uses the vCard format to store contact info, which contains a hasEmail field. The hasEmail field requires a mailto:
prefix before the email address, which is obviously not intuitive to have to enter in the form. Let's create a new email widget available from the UI schema that handles this out of the view of the user.
Acceptance criteria
- Widget hides
mailto
prefix from input when editing existing vCard with this value - Prefix is added after submission before validation
- Input gets html5 "type=email" attribute for initial browser validation
- In default dataset.ui schema,
hasEmail
is assigned to the widget
Upon further review, this is a problem more of our own making. We do want to fix the form to deal better with hasEmail
values that include the mailto:
prefix, but in the metadata that triggered the issue we are not harvesting from a third party and can simply remove them ourselves. De-prioritizing for the time being.
@dafeder : I am currently also stumbling into this.
The vcard format requires the mailto: prefix for the hasEmail property. Therefore this is added in the demo content before the email address, like this: mailto:[email protected]
Now data.json is outputting the vcard:hasEmail with the mailto prefix.
But upon saving the dkan dataset in the drupal backend, you are getting "invalid email" message (probably from HTML-5 validation?) and cannot save until you remove the mailto prefix. Now if you remove the mailto prefix the vcard:hasEmail property is no longer valid I suppose.
So this seems to be an issue at hand. If you are entering datasets via the backend you are not able to provide valid vcard:hasEmail property as far as I can see?
Imho the mailto prefix should be automatically set on the hasEmail property. Only on output, but not in the data?
see #3966 for possible fix.
Can probably be improved, but should do it for the moment. First three acceptance criterias might be met. About the last one I am not sure, whether it is really necessary to have a separate widget.
It's not so easy (for me perhaps) to get into the output of data.json and just inject it there. So I opted for inserting mailto: into the data saved (Prefix is added after submission before validation).