Use hint text instead of Django help text for providing the help for
EmailsField and clarify the text displayed when the input is invalid so it's hopefully more clear what happens - Legacy-Id: 8272
This commit is contained in:
parent
691befb126
commit
a1a13323d2
|
@ -32,7 +32,7 @@ class GroupForm(forms.Form):
|
|||
chairs = EmailsField(label="Chairs", required=False)
|
||||
secretaries = EmailsField(label="Secretaries", required=False)
|
||||
techadv = EmailsField(label="Technical Advisors", required=False)
|
||||
delegates = EmailsField(label="Delegates", required=False, help_text=mark_safe("Type in name to search for person<br>Chairs can delegate the authority to update the state of group documents - max %s persons at a given time" % MAX_GROUP_DELEGATES))
|
||||
delegates = EmailsField(label="Delegates", required=False, help_text=mark_safe("Chairs can delegate the authority to update the state of group documents - max %s persons at a given time" % MAX_GROUP_DELEGATES), max_entries=MAX_GROUP_DELEGATES)
|
||||
ad = forms.ModelChoiceField(Person.objects.filter(role__name="ad", role__group__state="active").order_by('name'), label="Shepherding AD", empty_label="(None)", required=False)
|
||||
parent = forms.ModelChoiceField(Group.objects.filter(state="active").order_by('name'), empty_label="(None)", required=False)
|
||||
list_email = forms.CharField(max_length=64, required=False)
|
||||
|
|
|
@ -31,7 +31,7 @@ def stream_documents(request, acronym):
|
|||
return render_to_response('group/stream_documents.html', {'stream':stream, 'docs':docs, 'meta':meta }, context_instance=RequestContext(request))
|
||||
|
||||
class StreamEditForm(forms.Form):
|
||||
delegates = EmailsField(label="Delegates", required=False, help_text=u"Type in name to search for person")
|
||||
delegates = EmailsField(label="Delegates", required=False)
|
||||
|
||||
def stream_edit(request, acronym):
|
||||
group = get_object_or_404(Group, acronym=acronym)
|
||||
|
|
|
@ -22,12 +22,14 @@ class EmailsField(forms.CharField):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs["max_length"] = 1000
|
||||
if not "help_text" in kwargs:
|
||||
kwargs["help_text"] = "Type in name to search for person"
|
||||
self.max_entries = kwargs.pop("max_entries", None)
|
||||
hint_text = kwargs.pop("hint_text", "Type in name or email to search for person and email address")
|
||||
|
||||
super(EmailsField, self).__init__(*args, **kwargs)
|
||||
|
||||
self.widget.attrs["class"] = "tokenized-field"
|
||||
self.widget.attrs["data-ajax-url"] = lazy(urlreverse, str)("ajax_search_emails") # make this lazy to prevent initialization problem
|
||||
self.widget.attrs["data-hint-text"] = hint_text
|
||||
if self.max_entries != None:
|
||||
self.widget.attrs["data-max-entries"] = self.max_entries
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@ function setupTokenizedField(field) {
|
|||
pre = JSON.parse((field.attr("data-pre") || "").replace(/"/g, '"'));
|
||||
|
||||
field.tokenInput(field.attr("data-ajax-url"), {
|
||||
hintText: "",
|
||||
preventDuplicates: true,
|
||||
prePopulate: pre,
|
||||
tokenLimit: field.attr("data-max-entries")
|
||||
tokenLimit: field.attr("data-max-entries"),
|
||||
noResultsText: "No results - cannot use this entry",
|
||||
hintText: field.attr("data-hint-text")
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue