All RazorForms tag helpers use two main template files to create their output. Validity-aware tag helpers use ~/RazorFormsTemplates/Partials/ValidityAwareContent.cshtml
, while validity-unaware tag helpers use ~/RazorFormsTemplates/Partials/Content.cshtml
.
Parts of the markup can be modified or disabled via configuration. For more information on configuring RazorForms, see configuration. If you want to make changes to the markup that aren't supported by configuration, you can create custom templates.
<div> <!-- component wrapper -->
<div> <!-- label wrapper, disable in configuration -->
<label>...</label>
</div>
<div> <!-- input wrapper, disable in configuration -->
<input/>
</div>
</div>
The entire component is wrapped with a <div>
. This cannot be disabled in configuration. The component wrapper classes can be set with FormComponentOptions.ComponentWrapperClasses.
The <label>
is wrapped with its own <div>
. This can be disabled in configuration. The label wrapper classes can be set with FormComponentOptions.LabelWrapperClasses.
The <label>
classes can be set with FormComponentOptions.LabelClasses.
The <input>
is wrapped with its own <div>
. This can be disabled in configuration. The input wrapper classes can be set with FormComponentOptions.InputWrapperClasses.
The <input>
classes can be set with FormComponentOptions.InputClasses.
true
, the <label>
and <input>
are rendered directly inside the component wrapper, instead of inside their own <div>
wrapperstrue
, the <input>
and its wrapper <div>
are rendered first inside the component wrappertrue
, the <input>
and its wrapper <div>
are rendered inside the <label>
instead of adjacent to it<div> <!-- component wrapper -->
<div> <!-- input block wrapper -->
<div> <!-- label wrapper, disable in configuration -->
<label>...</label>
</div>
<div> <!-- input wrapper, disable in configuration -->
<!-- type varies based on model -->
<input/>
</div>
</div>
<ul> <!-- error wrapper, only rendered if errors are present -->
<li>...</li> <!-- error -->
</ul>
</div>
The entire component is wrapped with a <div>
. This cannot be disabled in configuration. The component wrapper supports the following configuration options:
The <input>
and <label>
are wrapped with a <div>
. This cannot be disabled in configuration. The input block wrapper supports the following configuration options:
The <label>
is wrapped with its own <div>
. This can be disabled in configuration. The label wrapper supports the following configuration options:
The <label>
supports the following configuration options:
The <input>
is wrapped with its own <div>
. This can be disabled in configuration. The input wrapper supports the following configuration options:
The <input>
supports the following configuration options:
The <ul>
wraps around error messages. This cannot be disabled in configuration. Because the error wrapper is intended only to convey error information, it doesn't support validity-based classes. The error wrapper supports the following configuration options:
The <li>
contains error messages. This cannot be disabled in configuration. Because the error is intended only to convey error information, it doesn't support validity-based classes. The error supports the following configuration options:
true
, the <label>
and <input>
are rendered directly inside the input block wrapper, instead of inside their own <div>
wrapperstrue
, the <input>
and its wrapper <div>
are rendered first inside the input block wrappertrue
, the <input>
and its wrapper <div>
are rendered inside the <label>
instead of adjacent to ittrue
, the <ul>
that contains errors is always rendered, even if empty