I've been working on an extension for civicrm and am using the API to retrieve fields to be used in forms presented to the end user.
I am using the 'html.type' returned to determine which type of html form input to display (text, textarea, select, etc.).
The first issue is that the returned values don't match up with html input types, for example:
CRM.api3('Contact', 'getfield', {
"sequential": 1,
"name": "birth_date",
"action": "get"
})
returns
"values": {
"name": "birth_date",
...
"html": {
"type": "Select Date"
}
}
but Select Date
is not an html input type. This isn't too much of a problem as long as Civi is consistent with what it calls a date field. But in the above example, the field birth_date
expects a date without a time.
But calling
CRM.api3('Event', 'getfield', {
"sequential": 1,
"name": "event_start_date",
"action": "get"
}
returns the same 'html.type' value:
"values": {
"name": "start_date",
...
"html": {
"type": "Select Date"
},
...
}
and yet this field expects a datetime, not just a date.
So if you're trying (as I am) to have an extension operate on a list of fields which can be selected by the user and so aren't known in advance, I can't see any way to differentiate between the two cases.
I may be missing something obvious, but I can't work out what.