cancel
Showing results for 
Search instead for 
Did you mean: 

How to require urlInput on custom component ui_component form?

How to require urlInput on custom component ui_component form?

I'm trying to make the urlInput a required field in the ui_component form in a custom component. I'm able to make other fields required using the below validation method, but it won't work for urlInput.

 

The user is able to save the form even with a blank text field. That, coupled with the asterisk being next to the URL field (see image below) leads me to believe that the "required-entry" is applying to the the link type drop down and not the text field where the user would enter a URL or select a site link.

 

Does anyone know how I could make the URL field a required one within the custom component form?

 

Code:

...
<urlInput name="link_url" sortOrder="30" template="Magento_PageBuilder/form/element/url-input"> <settings> <dataType>text</dataType> <label translate="true">Link</label> <dataScope>link_url</dataScope> <urlTypes class="Magento\Ui\Model\UrlInput\LinksConfigProvider"/> <validation> <rule name="required-entry" xsi:type="boolean">true</rule> </validation> </settings> </urlInput>
...

 

With that code in the ui_component.xml, it shows up like this:Incorrect Validation.png

If this image isn't showing up in the post, it can be seen here too: https://ibb.co/xs901hL