Skip to content

Commit

Permalink
Override labels position settings in group level
Browse files Browse the repository at this point in the history
Sometimes we have situations when some of our groups need rather another label positioning than the one set to the whole form. We can make it possible by allowing the groups override the form / details global settings.
  • Loading branch information
jaanusnurmoja committed Feb 21, 2014
1 parent 4bb635c commit 4c8d424
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ COM_FABRIK_FIELD_LABELS_ABOVE_DESC="Bootstrapped forms only - select whether the
COM_FABRIK_FIELD_LABELS_ABOVE_LABEL="Labels position"
COM_FABRIK_FIELD_LABELS_ABOVE_DETAILS_DESC="Bootstrapped details view only - select whether the labels should be shown above the form, to the left of the form or don't show. If groups have multiple columns then if shown labels will automatically be placed above fields rather than to the left of fields."
COM_FABRIK_FIELD_LABELS_ABOVE_DETAILS_LABEL="Labels position (details)"
COM_FABRIK_FIELD_LABELS_ABOVE_GLOBAL="Use global"
COM_FABRIK_FIELD_LABELS_ABOVE_LEFT="Left"
COM_FABRIK_FIELD_LABELS_ABOVE_ABOVE="Above"
COM_FABRIK_FIELD_LABELS_ABOVE_NONE="None"
Expand Down
23 changes: 23 additions & 0 deletions administrator/components/com_fabrik/models/forms/group.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="labels_above"
type="radio"
class="btn-group"
default="-1"
label="COM_FABRIK_FIELD_LABELS_ABOVE_LABEL"
description="COM_FABRIK_FIELD_LABELS_ABOVE_DESC" >
<option value="-1">COM_FABRIK_FIELD_LABELS_ABOVE_GLOBAL</option>
<option value="0">COM_FABRIK_FIELD_LABELS_ABOVE_LEFT</option>
<option value="1">COM_FABRIK_FIELD_LABELS_ABOVE_ABOVE</option>
<option value="2">COM_FABRIK_FIELD_LABELS_ABOVE_NONE</option>
</field>

<field name="labels_above_details"
type="radio"
class="btn-group"
default="-1"
label="COM_FABRIK_FIELD_LABELS_ABOVE_DETAILS_LABEL"
description="COM_FABRIK_FIELD_LABELS_ABOVE_DETAILS_DESC" >
<option value="-1">COM_FABRIK_FIELD_LABELS_ABOVE_GLOBAL</option>
<option value="0">COM_FABRIK_FIELD_LABELS_ABOVE_LEFT</option>
<option value="1">COM_FABRIK_FIELD_LABELS_ABOVE_ABOVE</option>
<option value="2">COM_FABRIK_FIELD_LABELS_ABOVE_NONE</option>
</field>
</fieldset>
</fields>
</form>
2 changes: 2 additions & 0 deletions components/com_fabrik/models/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,8 @@ public function getGroupProperties(&$formModel)
$group->columns = $params->get('group_columns', 1);
$group->splitPage = $params->get('split_page', 0);
$group->showLegend = $this->showLegend($group);
$group->labels = $params->get('labels_above', -1);
$group->dlabels = $params->get('labels_above_details', -1);

if ($this->canRepeat())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
?>
<div class="row-striped">
<?php
$group = $this->group;
$rowStarted = false;
foreach ($this->elements as $element) :
$this->element = $element;
Expand All @@ -34,7 +35,7 @@
$rowStarted = true;
endif;
$style = $element->hidden ? 'style="display:none"' : '';
$labels_above = $this->params->get('labels_above_details', 0);
$labels_above = (!$group->dlabels || (int) $group->dlabels == -1) ? $this->params->get('labels_above_details', 0) : (int) $group->dlabels;

if ($labels_above == 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// No direct access
defined('_JEXEC') or die('Restricted access');

$group = $this->group;
$rowStarted = false;
foreach ($this->elements as $element) :
$this->element = $element;
Expand All @@ -34,7 +34,7 @@
?>
<div class="control-group <?php echo $element->containerClass . $span; ?>" <?php echo $style?>>
<?php
$labels_above = $this->params->get('labels_above', 0);
$labels_above = (!$group->dlabels || (int) $group->dlabels == -1) ? $this->params->get('labels_above_details', 0) : (int) $group->dlabels;
if ($labels_above == 1)
{
echo $this->loadTemplate('group_labels_above');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// No direct access
defined('_JEXEC') or die('Restricted access');

$group = $this->group;
$rowStarted = false;
foreach ($this->elements as $element) :
$this->element = $element;
Expand All @@ -34,7 +34,7 @@
?>
<div class="control-group <?php echo $element->containerClass . $span; ?>" <?php echo $style?>>
<?php
$labels_above = $this->params->get('labels_above', 0);
$labels_above = (!$group->labels || $group->labels == -1) ? $this->params->get('labels_above', 0) : $group->labels;
if ($labels_above == 1)
{
echo $this->loadTemplate('group_labels_above');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// No direct access
defined('_JEXEC') or die('Restricted access');

$group = $this->group;
$rowStarted = false;
foreach ($this->elements as $element) :
$this->element = $element;
Expand All @@ -34,7 +34,7 @@
?>
<div class="control-group <?php echo $element->containerClass . $span; ?>" <?php echo $style?>>
<?php
$labels_above = $this->params->get('labels_above', 0);
$labels_above = (!$group->labels || $group->labels == -1) ? $this->params->get('labels_above', 0) : $group->labels;
if ($labels_above == 1)
{
echo $this->loadTemplate('group_labels_above');
Expand Down

0 comments on commit 4c8d424

Please sign in to comment.