I am trying to create a new button for a Custom object to add it in community.On clicking the button lightning-record-form will be displayed in edit mode to show input fields of the layout but what ever fields are required on the layout are not showed as required on the form.

2 Answers 2


As of Winter '20 you can make the lightning-input-field component required

lightning-input-field The following attribute is new.

  • required—To make an input field required only on the client, include the required attribute. Use this attribute to require a value in a field before the form can be submitted, and the field isn’t marked required in Setup. If the field doesn’t have a value, the component’s client-side validation catches the error before the form data is submitted to the server.



lightning-record-edit-form will not take care of fields that are required on the page layout. If a field is required on a field level, that will be taken-care by lightning data service. You need to explicitly check the field in your form which is not required on field level using onsubmit event.

   event.preventDefault();       // stop the form from submitting
   const fields = event.detail.fields;
     //do something
  • I was using this as an alternative for NavigationMixin to set defaultvalue for a field.
    – user70147
    Sep 10, 2019 at 17:30
  • You can use it for checking blank values too. In else condition, you can show some error toast or anything you want. Sep 10, 2019 at 17:34

You must log in to answer this question.

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