4
4
479112021-09-18 17:09:01
Joomla
47911, 2021-09-18 17:09:01

Does behavior exist in Joomla 4?

In general. Feeling Joomla 4 + component which "Looks like it works on Joomla 4".
Some pages give an error like this:

behavior::formvalidation not found.

I dug into the code - I see: A search for "JHTML::_('behavior." showed that it occurs only in "this very component". I understand that the construction of the form "JHTML::_('behavior.") does not work in Joomla 4? How to be? What analogue?
JHTML::_('behavior.formvalidation');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Rekun, 2021-09-22
@47911

The fourth is now the asset manager.

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
  ->useScript('form.validate')

An example is in /administrator/components/com_content/tmpl/article/edit.php.
You can read about the manager here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question