[SalesForce] LWC lightning-record-form Time field edit

I have a lightning-record-form for a custom object, which I show and allow to edit with the basic element's features:

<lightning-record-form record-id={opId} object-api-name="Operation__c" layout-type="Full" mode="view" style="padding: 0 10px;">
        </lightning-record-form>

The viewing and editing works well, EXCEPT for a Time type field, which for some reason I cannot edit, when in edit mode.
The field somehow shows the time value in it's long form: '02:00:00.000Z' instead of '02:00' in the object's creation form, and it's not possible to type/add/change/paste any text in the field. But you can delete the field's content…

This is quite problematic, as my users need to be able to edit this field in the form.
I couldn't find any documentation or help regarding this.

Does anybody know how to fix this?

Thanks for your help,

Daniel

Best Answer

I suspect (but have no firm documentation link) that time fields are simply not (yet) supported in lightning-record-form. It does appear that lightning-record-form uses lightning-input-field for editing (and you can see this in the open-source copy of lightning-record-form). lightning-input-field is not yet open-source, but the docs include a list of supported fields types; that list includes 'Date' and 'Date/Time', but does not include 'Time'.

There is an Idea posted to add this support, but like many good Ideas, it has little support so far... just 2 votes (and one of them mine). You will likely need to switch to lightning-edit-form and build a custom editor component for your Time fields. Edit to add: As @naga points out, lightning-input can handle time input, and if it meets your needs is simpler than a custom editor component. You will still need to switch to lightning-edit-form.

Related Topic