Back to Tag class

Method ajaxfield

public static void
ajaxfield
(mixed $selector = '#jform_tags', mixed $allowCustom = true)
This is just a proxy for the formbehavior.ajaxchosen method
Parameters
  • string $selector DOM id of the tag field
  • bool $allowCustom Flag to allow custom values
Returns
  • void
Since
  • 3.1
Deprecated
  • 5.0
Class: Tag
Project: Joomla

Method ajaxfield - Source code

/**
 * This is just a proxy for the formbehavior.ajaxchosen method
 *
 * @param   string   $selector     DOM id of the tag field
 * @param   boolean  $allowCustom  Flag to allow custom values
 *
 * @return  void
 *
 * @since   3.1
 *
 * @deprecated  5.0  Without replacement
 */
public static function ajaxfield($selector = '#jform_tags', $allowCustom = true)
{
    // Get the component parameters
    $params = ComponentHelper::getParams('com_tags');
    $minTermLength = (int) $params->get('min_term_length', 3);
    Text::script('JGLOBAL_KEEP_TYPING');
    Text::script('JGLOBAL_LOOKING_FOR');
    // Include scripts
    HTMLHelper::_('behavior.core');
    HTMLHelper::_('jquery.framework');
    HTMLHelper::_('formbehavior.chosen');
    HTMLHelper::_('script', 'legacy/ajax-chosen.min.js', array('version' => 'auto', 'relative' => true));
    Factory::getDocument()->addScriptOptions('ajax-chosen', array('url' => Uri::root() . 'index.php?option=com_tags&task=tags.searchAjax', 'debug' => JDEBUG, 'selector' => $selector, 'type' => 'GET', 'dataType' => 'json', 'jsonTermKey' => 'like', 'afterTypeDelay' => 500, 'minTermLength' => $minTermLength));
    // Allow custom values ?
    if ($allowCustom) {
        HTMLHelper::_('script', 'system/fields/tag.min.js', array('version' => 'auto', 'relative' => true));
        Factory::getDocument()->addScriptOptions('field-tag-custom', array('minTermLength' => $minTermLength, 'selector' => $selector, 'allowCustom' => Factory::getUser()->authorise('core.create', 'com_tags') ? $allowCustom : false));
    }
}