Changeset - 4fdf7ccd42dc
[Not reviewed]
default
0 1 0
Mads Kiilerich - 9 years ago 2017-01-06 01:43:51
mads@kiilerich.com
templates: use valid ids for input fields in hook settings so labels can reference them correctly

h.text will generate safe ids based on the name ... but these ids are not
available in the template for referencing from <label for=...>.

Instead, generate safe ids for the input fields.
1 file changed with 8 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/admin/settings/settings_hooks.html
Show inline comments
 
@@ -2,10 +2,11 @@
 
<div class="form">
 
    <div class="form-horizontal">
 
      % for hook in c.hooks:
 
        <% input_id = hook.ui_key.replace('.', '_') %>
 
        <div class="form-group">
 
            <label class="control-label" for="${hook.ui_key}">${hook.ui_key}</label>
 
            <label class="control-label" for="${input_id}">${hook.ui_key}</label>
 
            <div style="margin-left:280px">
 
              ${h.text(hook.ui_key,hook.ui_value,size=60,readonly="readonly",class_='form-control')}
 
              ${h.text(hook.ui_key,hook.ui_value,id=input_id,size=60,readonly="readonly",class_='form-control')}
 
            </div>
 
        </div>
 
      % endfor
 
@@ -20,12 +21,13 @@ ${h.form(url('admin_settings_hooks'), me
 
    <div class="form-horizontal">
 

	
 
        %for hook in c.custom_hooks:
 
            <% input_id = hook.ui_key.replace('.', '_') %>
 
            <div class="form-group form-inline" id="${'id%s' % hook.ui_id }">
 
                <label class="control-label" for="${hook.ui_key}">${hook.ui_key}</label>
 
                <label class="control-label" for="${input_id}">${hook.ui_key}</label>
 
                <div style="margin-left:280px">
 
                    ${h.hidden('hook_ui_key',hook.ui_key)}
 
                    ${h.hidden('hook_ui_value',hook.ui_value)}
 
                    ${h.text('hook_ui_value_new',hook.ui_value,size=60,class_='form-control')}
 
                    ${h.hidden('hook_ui_key',hook.ui_key,id='hook_ui_key_'+input_id)}
 
                    ${h.hidden('hook_ui_value',hook.ui_value,id='hook_ui_value_'+input_id)}
 
                    ${h.text('hook_ui_value_new',hook.ui_value,id=input_id,size=60,class_='form-control')}
 
                    <span class="btn btn-default btn-xs"
 
                        onclick="delete_hook(${hook.ui_id},'${'id%s' % hook.ui_id }')">
 
                        <i class="icon-minus-circled" style="color:#FF4444"></i>
0 comments (0 inline, 0 general)