Skip to main content

RoutertypeField

RoutertypeField extends Joomla's HiddenField to inject the current J2Commerce SEF router type as the field value. The rendered <input type="hidden"> carries either modern or legacy. Its only purpose is to act as a dependency target for Joomla showon conditions on sibling fields — it stores nothing meaningful and is never read back during form save.

Class Details

PropertyValue
ClassRoutertypeField
NamespaceJ2Commerce\Component\J2commerce\Administrator\Field
Fileadministrator/components/com_j2commerce/src/Field/RoutertypeField.php
ExtendsJoomla\CMS\Form\Field\HiddenField
Field type stringRoutertype
Since6.0.7

Behavior

getInput() reads ComponentHelper::getParams('com_j2commerce')->get('sef_router', 'modern'), assigns the result to $this->value, then calls parent::getInput(). The rendered output is a standard Joomla hidden input:

<input type="hidden" name="jform[router_type]" id="jform_router_type" value="modern"/>

XML Usage

<form addfieldprefix="J2Commerce\Component\J2commerce\Administrator\Field">
<fieldset name="routing">
<!-- The hidden dependency field -->
<field
name="router_type"
type="Routertype"
/>

<!-- Only shown when legacy router is active -->
<field
name="product_list_menu"
type="Productlistmenu"
label="COM_J2COMMERCE_FIELD_PRODUCT_LIST_MENU"
showon="router_type:legacy"
/>

<!-- Only shown when modern router is active -->
<field
name="catid"
type="RouterModalCategory"
label="JGLOBAL_CHOOSE_CATEGORY_LABEL"
showon="router_type:modern"
/>
</fieldset>
</form>

XML Attributes

AttributeRequiredDescription
nameYesField name. Must match the showon reference in sibling fields (e.g. router_type).
typeYesMust be Routertype.

No other attributes are used. label is ignored since this is a hidden field.

showon Values

ValueMeaning
modernActive when sef_router parameter is modern (the default).
legacyActive when sef_router parameter is legacy.

Usage Notes

  • Place this field before any sibling fields that use showon="router_type:...". Joomla evaluates showon by field name, so the hidden field must exist in the rendered form.
  • The field does not need to be in the same fieldset as its dependants — showon works across fieldsets in the same form.
  • Because the field value is set from component params at render time and is not user-editable, it is immune to tampering via form submission.