<h2>{i18n}Manage conditional fieldset{/i18n}</h2>

<p class="descriptiveText">{i18n}Conditional fieldsets allow you to restrict the options
a user has for values in some fields based on the values in other fields, allowing you to say that 
the values of one field are restricted to a certain subset of values if another field
has a specific value.  For example, you could say that if the field "Street" is "Jeffrey", 
then the field "Residents" must be one of "Jones","Smith" or "Friedman".{/i18n}</p>


{* don't show warnings until the basics are done. *}

{if ($oMasterField && empty($free_fields))}
{if $sIncomplete}
<div class="ktInfoMessage">
<span>{i18n}This conditional fieldset is marked such that it
cannot be used.  The system automatically checks whether the fieldset is useable,
and if not it will prevent it being used in a "conditional" fashion.  Please correct
the issues identified below.{/i18n}</span>
</div>
{/if}

{if $sIncomplete}
<div class="ktErrorMessage">
<span>{i18n}This error prevents this fieldset from being set
to complete{/i18n}: {$sIncomplete}</span>
</div>
{/if}
{/if}

<h2>{i18n}View Overview{/i18n}</h2>
<form action="{$smarty.server.PHP_SELF}" method="POST">
<input type="hidden" name="action" value="viewOverview" />
<input type="hidden" name="fieldset_id" value="{$oFieldset->getId()}" />
<input type="submit" name="submit" value="{i18n}View Overview{/i18n}" />
</form>


<h2>{i18n}Conditional type{/i18n}</h2>


<form action="{$smarty.server.PHP_SELF}" method="POST">
<input type="hidden" name="action" value="changeToComplex" />
<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}" />
<input type="submit" name="submit" value="{i18n}Change to complex{/i18n}" />
</form>

{/if}

<p>{i18n}Changing the conditional type set will remove all existing field
ordering!{/i18n}</p>



{if !$oMasterField}
<h2>{i18n}Master field{/i18n}</h2>
{i18n}No master field is set, please select the master field{/i18n}:

<form action="{$smarty.server.PHP_SELF}" method="POST">
<input type="hidden" name="action" value="setMasterField" />
<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}" />

{entity_select entities=$oFieldset->getFields() name="fFieldId"}
<input type="submit" name="submit" value="{i18n}Set master field{/i18n}" />
</form>

{else}

<form action="{$smarty.server.PHP_SELF}" method="POST">
<fieldset>
<legend>{i18n}Master field{/i18n}</legend>
<input type="hidden" name="action" value="setMasterField" />
<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}" />

<p class="descriptiveText">{i18n}In order to have a chain of conditions, one initial field
must be shown to the user.  This is called the <strong>master field</strong>.{/i18n}</p>

<div class="form">
<p class="descriptiveText important">{i18n}Changing the master field set will remove all existing field
ordering!{/i18n}</p>
{entity_select entities=$oFieldset->getFields() name="fFieldId" selected=$oMasterField->getId()}
</div>
<div class="form_actions">
<input type="submit" name="submit" value="{i18n}Change master field{/i18n}" />
</div>
</fieldset>
</form>



<h2>{i18n}Field ordering{/i18n}</h2>

{if $aFieldOrders}
<h3>{i18n}Existing ordering{/i18n}</h2>

<ul>
{foreach from=$aFieldOrders item=aRow}
{php}
$this->assign("oParentField", DocumentField::get($this->_tpl_vars['aRow']['parent_field_id']));
$this->assign("oChildField", DocumentField::get($this->_tpl_vars['aRow']['child_field_id']));
{/php}
  <li>
    {$oParentField->getName()}
<span class="descriptiveText">{i18n}controls the values available in{/i18n}</span> 
    {$oChildField->getName()}
</li>
{/foreach}
</ul>
{/if}

{ if $free_fields }


<form action="{$smarty.server.PHP_SELF}" method="POST">
<fieldset>
<input type="hidden" name="fFieldsetId" value="{$oFieldset->getId()}" />
<input type="hidden" name="action" value="orderFields" />

<legend>{i18n}Order Fields{/i18n}</legend>

<div class="field">
<p class="descriptiveText">{i18n}The value of the field{/i18n}</p>
{entity_select entities=$parent_fields name="fParentFieldId"}
</div>

<div class="field">
<p class="descriptiveText">{i18n}controls the values of the following fields{/i18n}</p>
{entity_select entities=$free_fields name="fFreeFieldIds[]" multiple="yes"}
</div>

<div class="form_actions">
<input type="submit" name="submit" value="{i18n}Order{/i18n}" />
</div>
</fieldset>
</form>
{/if}

{/if}



<h2>{i18n}Rename Behaviours{/i18n}</h2>
<form action="{$smarty.server.PHP_SELF}" method="POST">
<input type="hidden" name="action" value="renameBehaviours" />
<input type="hidden" name="fieldset_id" value="{$oFieldset->getId()}" />
<input type="submit" name="submit" value="{i18n}Rename Behaviours{/i18n}" />
</form>
