Skip to content

Commit

Permalink
Adding enable / disable to checkbox custom PHP options
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Dec 1, 2014
1 parent d0a2044 commit e291b32
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
20 changes: 20 additions & 0 deletions components/com_fabrik/models/element.php
Expand Up @@ -3564,6 +3564,26 @@ protected function getSubOptionLabels()

return $opts;
}

/**
* Get sub option enabled/disabled state
*
* @return array
*/

protected function getSubOptionEnDis()
{
$opts = array();
$phpOpts = $this->getPhpOptions();
if ($phpOpts)
{
foreach ($phpOpts as $phpOpt)
{
$opts[] = $phpOpt->disable;
}
}
return $opts;
}

/**
* Should we get the elements sub options via the use of eval'd parameter setting
Expand Down
8 changes: 6 additions & 2 deletions plugins/fabrik_element/dropdown/dropdown.php
Expand Up @@ -57,6 +57,7 @@ public function render($data, $repeatCounter = 0)
$params = $this->getParams();
$values = $this->getSubOptionValues();
$labels = $this->getSubOptionLabels();
$endis = $this->getSubOptionEnDis();
$multiple = $params->get('multiple', 0);
$multisize = $params->get('dropdown_multisize', 3);
$selected = (array) $this->getValue($data, $repeatCounter);
Expand All @@ -82,10 +83,13 @@ public function render($data, $repeatCounter = 0)
}

$tmpLabel = JArrayHelper::getValue($labels, $i);

$disable = JArrayHelper::getValue($endis, $i);

// For values like '1"'
$tmpval = htmlspecialchars($tmpval, ENT_QUOTES);
$opts[] = JHTML::_('select.option', $tmpval, $tmpLabel);
$opt = JHTML::_('select.option', $tmpval, $tmpLabel);
$opt->disable = $disable;
$opts[] = $opt;

if (in_array($tmpval, $selected))
{
Expand Down

0 comments on commit e291b32

Please sign in to comment.