Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<?php if (!empty($fieldSet->showon)) : ?>
<?php JHtml::_('jquery.framework'); ?>
<?php JHtml::_('script', 'jui/cms.js', array('version' => 'auto', 'relative' => true)); ?>
<?php $dataShowOn = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($this->formControl, $fieldSet->showon)) . '\''; ?>
<?php $dataShowOn = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($fieldSet->showon, $this->formControl)) . '\''; ?>
<?php endif; ?>
<?php $label = empty($fieldSet->label) ? 'COM_CONFIG_' . $name . '_FIELDSET_LABEL' : $fieldSet->label; ?>
<li<?php echo $dataShowOn; ?>><a data-toggle="tab" href="#<?php echo $name; ?>"><?php echo JText::_($label); ?></a></li>
Expand All @@ -80,7 +80,7 @@
<?php if ($field->showon) : ?>
<?php JHtml::_('jquery.framework'); ?>
<?php JHtml::_('script', 'jui/cms.js', array('version' => 'auto', 'relative' => true)); ?>
<?php $dataShowOn = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($field->formControl, $field->showon)) . '\''; ?>
<?php $dataShowOn = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($field->showon, $field->formControl, $field->group)) . '\''; ?>
<?php endif; ?>
<?php if ($field->hidden) : ?>
<?php echo $field->input; ?>
Expand Down
2 changes: 1 addition & 1 deletion layouts/joomla/content/options_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{
JHtml::_('jquery.framework');
JHtml::_('script', 'jui/cms.js', array('version' => 'auto', 'relative' => true));
$datashowon = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($field->formControl, $field->showon)) . '\'';
$datashowon = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($field->showon, $field->formControl, $field->group)) . '\'';
}
?>
<div class="control-group"<?php echo $datashowon; ?>>
Expand Down
2 changes: 1 addition & 1 deletion layouts/joomla/searchtools/default/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<?php if ($field->showon) : ?>
<?php JHtml::_('jquery.framework'); ?>
<?php JHtml::_('script', 'jui/cms.js', array('version' => 'auto', 'relative' => true)); ?>
<?php $dataShowOn = " data-showon='" . json_encode(JFormHelper::parseShowOnConditions($field->formControl, $field->showon)) . "'"; ?>
<?php $dataShowOn = " data-showon='" . json_encode(JFormHelper::parseShowOnConditions($field->showon, $field->formControl, $field->group)) . "'"; ?>
<?php endif; ?>
<div class="js-stools-field-filter"<?php echo $dataShowOn; ?>>
<?php echo $field->input; ?>
Expand Down
3 changes: 2 additions & 1 deletion libraries/joomla/form/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ public function renderField($options = array())

if ($this->showon)
{
$options['rel'] = ' data-showon=\'' . json_encode(JFormHelper::parseShowOnConditions($this->formControl, $this->showon)) . '\'';
$options['rel'] = ' data-showon=\'' .
json_encode(JFormHelper::parseShowOnConditions($this->showon, $this->formControl, $this->group)) . '\'';
$options['showonEnabled'] = true;
}

Expand Down
14 changes: 11 additions & 3 deletions libraries/joomla/form/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,15 @@ protected static function addPath($entity, $new = null)
/**
* Parse the show on conditions
*
* @param string $formControl Form name.
* @param string $showOn Show on conditions.
* @param string $formControl Form name.
* @param string $group The dot-separated form group path.
*
* @return array Array with show on conditions.
*
* @since __DEPLOY_VERSION__
*/
public static function parseShowOnConditions($formControl, $showOn)
public static function parseShowOnConditions($showOn, $formControl = null, $group = null)
{
// Process the showon data.
if (!$showOn)
Expand All @@ -338,13 +339,20 @@ public static function parseShowOnConditions($formControl, $showOn)
$showOnData = array();
$showOnParts = preg_split('#\[AND\]|\[OR\]#', $showOn);

$formPath = $formControl ?: '';

if ($formPath && $group)
{
$formPath .= '[' . $group . ']';
}

foreach ($showOnParts as $showOnPart)
{
$compareEqual = strpos($showOnPart, '!:') === false;
$showOnPartBlocks = explode(($compareEqual ? ':' : '!:'), $showOnPart, 2);

$showOnData[] = array(
'field' => $formControl ? $formControl . '[' . $showOnPartBlocks[0] . ']' : $showOnPartBlocks[0],
'field' => $formPath ? $formPath . '[' . $showOnPartBlocks[0] . ']' : $showOnPartBlocks[0],
'values' => explode(',', $showOnPartBlocks[1]),
'sign' => $compareEqual === true ? '=' : '!=',
'op' => preg_match('#^\[(AND|OR)\]#', $showOnPart, $matches) ? $matches[1] : '',
Expand Down