﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11432	prepopulated_fields should work for non-slug fields	Flo Ledermann	nobody	"I repeatedly have the use case where a CharField should be autopopulated from another one (classical example is a title and a headline, where the headline should be initialized with the title by default)
When using prepopulated_fields, the current hardcoded behaviour is to URLify the field's contents (this is done in the javascript generated in django/contrib/admin/templates/admin/prepopulated_fields_js.html). Current code (prepopulated_fields_js.html:7):

{{{
        if (!e._changed) { e.value = URLify({% for innerdep in field.dependencies %}document.getElementById(""{{ innerdep.auto_id }}"").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:""50"" }}); }
}}}

I replaced this by a hack to see if the field is a RegexField, and if not just copy the concatenated values:

{{{
        {# a *lot* of things are named 'field' in django ;) #}
        {% if field.field.field.regex %} 
        if (!e._changed) { e.value = URLify({% for innerdep in field.dependencies %}document.getElementById(""{{ innerdep.auto_id }}"").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:""50"" }}); }
        {% else %}
        if (!e._changed) { e.value = {% for innerdep in field.dependencies %}document.getElementById(""{{ innerdep.auto_id }}"").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}; }
        {% endif %}
}}}

I guess you guys have better ideas how to put this on a more solid basis, but I wanted to share the requirement and code with you."	Uncategorized	closed	contrib.admin	1.0	Normal	duplicate			Unreviewed	0	0	0	0	0	0
