0

I have the following LWC Component: " " I have created a Page Layout for the recordType and marked a few fields as required on the Page Layout. While the fields are being pulled into the layout, they are not being shown as required, and I am able to save the Record without populating information in the fields. Is there anything extra that I need to do so that the required symbol comes up against the field?

3
  • can you share your code
    – User6670
    Feb 13, 2020 at 8:53
  • have you specified RecordId on the component as attribute?
    – ytiq
    Feb 13, 2020 at 8:57
  • This is the code, I am using this to create a record, hence no need to specify Record Id: <lightning-record-form object-api-name={objectAPIName} record-type-id={recordTypeId} layout-type="Full" onsuccess={handleSuccess}> </lightning-record-form>
    – Nevds
    Feb 13, 2020 at 9:14

2 Answers 2

1

From the documentation. It only marks required on Object Level.

https://developer.salesforce.com/docs/component-library/bundle/lightning-record-form/documentation

lightning-record-form renders a field as required only if the field is marked as required on the object. If a field is marked as required only on a page layout, the form doesn't render the field with the styling or validation for a required field.

1
  • Thank You. I totally missed that in the documentation
    – Nevds
    Feb 13, 2020 at 9:21
1

As ytiq already answered lightning-record-form renders a field as required only if the field is marked as required on the object but you can use lightning record edit form with lightning input field with required attribute to make it required.

https://releasenotes.docs.salesforce.com/en-us/winter20/release-notes/rn_lwc_components.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .