0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 19:22:14 +02:00
postfixadmin/templates/editform.tpl

141 lines
8.2 KiB
Smarty
Raw Normal View History

<form name="edit_{$table}" method="post" action="" class="form-horizontal">
<div id="edit_form" class="panel panel-default">
<div class="panel-heading"><h4>{$formtitle}</h4></div>
<div class="panel-body enable-asterisk">
<input class="flat" type="hidden" name="table" value="{$table}"/>
<input class="flat" type="hidden" name="token" value="{$smarty.session.PFA_token|escape:"url"}"/>
{foreach key=key item=field from=$struct}
{if $field.display_in_form == 1}
{if $table == 'foo' && $key == 'bar'}
<div class="form-group">Special handling (complete table row) for {$table} / {$key}</div>
{else}
<div class="form-group {if $fielderror.{$key}}has-error{/if}">
<label class="col-md-4 col-sm-4 control-label" for="{$key}">{$field.label}</label>
<div class="col-md-6 col-sm-8">
{if $field.editable == 0}
{if $field.type == 'enma'}
{$struct.{$key}.options.{$value_{$key}}}
{else}
{$value_{$key}}
{/if}
{else}
{if $table == 'foo' && $key == 'bar'}
Special handling (td content) for {$table} / {$key}
{elseif $field.type == 'bool'}
<div class="checkbox"><label>
<input type="checkbox" value='1'
name="value[{$key}]"{if {$value_{$key}} == 1} checked="checked"{/if}/>
</label></div>
{elseif $field.type == 'enum'}
<select class="form-control" name="value[{$key}]" id="{$key}">
{html_options output=$struct.{$key}.options values=$struct.{$key}.options selected=$value_{$key}}
</select>
{elseif $field.type == 'enma'}
<select class="form-control" name="value[{$key}]" id="{$key}">
{html_options options=$struct.{$key}.options selected=$value_{$key}}
</select>
{elseif $field.type == 'list'}
2022-03-21 14:04:19 +01:00
<input type="text" class="form-control" style="margin-bottom : 25px;" id="id_searchDomains" onkeyup="searchDomains()" placeholder="Search for domains..." title="search domains">
2022-03-21 12:44:26 +01:00
<ul id="domainsList" name="value[{$key}][]" style="max-height : 250px; overflow: auto;">
2022-03-21 09:30:25 +01:00
{foreach from=$struct.{$key}.options item=domain}
<li>
2022-03-21 15:21:50 +01:00
{assign var=flag value=0}
{foreach from=$value_{$key} item=selectedDomain}
{if $domain == $selectedDomain }
<input type="checkbox" checked name="value[{$key}][]" value="{$domain}" id="{$domain}_id" />
<label for="{$domain}_id">{$domain}</label>
2022-03-21 15:21:50 +01:00
{assign var=flag value=$flag+1}
{/if}
{/foreach}
2022-03-21 15:08:14 +01:00
2022-03-21 15:21:50 +01:00
{if $flag == 0 }
<input type="checkbox" name="value[{$key}][]" value="{$domain}" id="{$domain}_id" />
<label for="{$domain}_id">{$domain}</label>
{/if}
2022-03-21 09:30:25 +01:00
</li>
{/foreach}
2022-03-21 15:21:50 +01:00
2022-03-21 09:30:25 +01:00
</ul>
{elseif $field.type == 'pass' || $field.type == 'b64p'}
<input class="form-control" type="password" name="value[{$key}]" {if $key == 'password' || $key == 'password2'}autocomplete="new-password"{/if}/>
{elseif $field.type == 'txtl'}
<textarea class="form-control" rows="10" cols="35" name="value[{$key}]">{foreach key=key2 item=field2 from=$value_{$key}}{$field2}&#10;{/foreach}</textarea>
{elseif $field.type == 'txta'}
2022-06-21 01:55:36 +02:00
<textarea class="form-control" rows="10" cols="35" name="value[{$key}]">{$value_{$key}}</textarea>
{else}
<input class="form-control" type="text" name="value[{$key}]"
value="{$value_{$key}}"/>
{/if}
{/if}
{if $table == 'foo' && $key == 'bar'}
<span class="help-block">Special handling (td content) for {$table} / {$key}</span>
{else}
{if $fielderror.{$key}}
<span class="help-block">{$fielderror.{$key}}</span>
{else}
<span class="help-block">{$field.desc}</span>
{/if}
{/if}
</div>
</div>
{/if}
{/if}
{/foreach}
</div>
<div class="panel-footer">
<div class="btn-toolbar" role="toolbar">
2022-03-17 09:16:28 +01:00
<div class="btn-group pull-right">
<button class="btn btn-primary" type="submit" name="submit">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span> {$submitbutton}
</button>
</div>
</div>
</div>
</div>
</form>
2022-03-21 12:44:26 +01:00
<script type="text/javascript">
function searchDomains(){
input = document.getElementById("id_searchDomains").value.toLowerCase();
ul = document.getElementById("domainsList");
2022-03-21 12:47:38 +01:00
li = ul.getElementsByTagName("li");
2022-03-21 12:44:26 +01:00
for (i=0; i< li. length; i++){
//get domain
domain = li[i].innerHTML.split('<label')[1].split('>')[1].split('</label')[0];
//if domain = input
if (domain.indexOf(input) > -1) {
li[i].style.display = "";
}else{
li[i].style.display = "none";
}
}
}
{if $struct.local_part.options.legal_chars }
// If set: Check for illegal characters in local part of username
// decode htmlentities
var div = document.createElement('div');
div.innerHTML = "{$struct.local_part.options.legal_char_warning}";
var decoded = div.firstChild.nodeValue;
const local_part = document.getElementsByName("value[local_part]");
local_part[0].tabIndex = -1
local_part[0].addEventListener("keydown", function(event){
var regex = new RegExp("{$struct.local_part.options.legal_chars}");
if (!regex.test(event.key)) {
event.preventDefault();
alert(decoded + ": " + event.key);
return false;
}
});
{/if}
2022-03-21 12:44:26 +01:00
</script>