Contents
How to create a custom Sitecore text field?
The field appears as a standard Sitecore Text field, but includes the Validate Button. The validation obviously fails. Let’s try with a regular email: And that concludes how simple it is to create a custom field in Sitecore. In later posts, we’ll go over more advanced fields.
How to get the current page in Sitecore?
For reference, though, here are the helpers: if you are trying to write code about the current request in rendering, you may want to look at the page Context. In the context of rendering, the page item is the root item that will be rendered. In these instances you can use the page context to get the information:
How to validate a field in Sitecore template?
Now, let’s create an items based on the template, and verify our field renders: Create an instance of your Sitecore Template, make sure your field renders The field appears as a standard Sitecore Text field, but includes the Validate Button. The validation obviously fails. Let’s try with a regular email:
How does the handlemessage function work in Sitecore?
We set the CSS class “scContentControl” on the field to align it with the design of text fields in Sitecore in general. We implement / override the HandleMessage function – this function handles messages sent in Sitecore. If the message matches emailfield:validate as specified in the previous section, then we know our validate button was clicked.
Which is an example of a custom field?
Creating a custom field is pretty simple. Let’s take the example of a simple email field. The field will store a single email. It will include a validation button for email validation as well. Other than that, it will function just like a regular text field.
https://www.youtube.com/watch?v=wE_aaFN7GvY