1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 09:24:21 +01:00

implementing adding default values to form

This commit is contained in:
kakwa 2015-06-09 09:19:58 +02:00
parent 68c481c390
commit e2497671cb
2 changed files with 14 additions and 5 deletions

View File

@ -445,7 +445,7 @@ class LdapCherry(object):
def adduser(self, **params):
""" add user page """
self._check_auth(must_admin=True)
form = self.temp_form.render(attributes=self.attributes.attributes)
form = self.temp_form.render(attributes=self.attributes.attributes, values=None)
return self.temp_adduser.render(form=form)
@cherrypy.expose
@ -464,5 +464,5 @@ class LdapCherry(object):
def selfmodify(self, **params):
""" self modify user page """
self._check_auth(must_admin=False)
form = self.temp_form.render(attributes=self.attributes.get_selfattributes())
form = self.temp_form.render(attributes=self.attributes.get_selfattributes(), values=None)
return self.temp_selfmodify.render(form=form)

View File

@ -2,18 +2,27 @@
<% attr = attributes[a] %>
<div class="form-group">
<div class="input-group">
<%
if not values is None and a in values:
value = ' value="'+ values[a] + '"'
value2 = '<option>'+ values[a] +'</option>'
else:
value = ''
value2 = ''
%>
<span class="input-group-addon" id="basic-addon1">${attr['display_name']}</span>
% if attr['type'] == 'string':
<input type="text" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required>
<input type="text" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required ${value}>
% elif attr['type'] == 'email':
<input type="email" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required data-error="email address is invalid">
<input type="email" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required ${value} data-error="email address is invalid">
% elif attr['type'] == 'int':
<input type="number" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required>
<input type="number" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required ${value}>
% elif attr['type'] == 'fix':
<input type="hidden" name="${a}" class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1" required value="${attr['value']}">
<span class="form-control" placeholder="${attr['description']}" aria-describedby="basic-addon1">${attr['value']}</span>
% elif attr['type'] == 'stringlist':
<select class="form-control" name="type">
${value2}
%for val in attr['values']:
<option>${val}</option>
%endfor