diff --git a/ckan/templates/group/partials/group_form.html b/ckan/templates/group/partials/group_form.html index 5c69538f65c..ccf086fd986 100644 --- a/ckan/templates/group/partials/group_form.html +++ b/ckan/templates/group/partials/group_form.html @@ -14,7 +14,7 @@

{{ _('Errors in form') }}

{% endif %} {{ form.input('title', label=_('Title'), id='field-title', placeholder=_('My Group'), data=data, errors=errors, classes=['control-full']) }} - {{ form.input('name', label=_('URL'), id='field-url', placeholder=_('my-group'), data=data, errors=errors, classes=['control-full']) }} + {{ form.prepend('name', label=_('URL'), prepend=h.url(controller='group', action='index') ~ '/', id='field-url', placeholder=_('my-group'), data=data, errors=errors) }} {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my group...'), data=data, errors=errors) }} {{ form.input('image_url', label=_('Image URL'), id='field-url', type='url', placeholder=_('http://example.com/my-image.jpg'), data=data, errors=errors, classes=['control-full']) }} {% if c.is_sysadmin or c.auth_for_change_state %} diff --git a/ckan/templates/macros/form.html b/ckan/templates/macros/form.html index 9b8da55a3ac..045303d4324 100644 --- a/ckan/templates/macros/form.html +++ b/ckan/templates/macros/form.html @@ -1,3 +1,24 @@ +{# +Creates all the markup required for an input element. Handles matching labels to +inputs, error messages and other useful elements. + +name - The name of the form parameter. +id - The id to use on the input and label. Convention is to prefix with 'field-'. +label - The human readable label. +value - The value of the input. The alternative is to pass in the data dict + which will use the name key as the value. +placeholder - Some placeholder text. +type - The type of input eg. email, url, date (default: text). +data - The data dict, used to look up the value using the name. +errors - The errors dict, used to look up the error using the name. +classes - An array of classes to apply to the control-group. + +Examples: + + {% import form from 'macros/form.html' %} + {{ form.input('title', label=_('Title'), data=data, errors=errors) }} + +#} {% macro input(name, id='', label='', value='', placeholder='', type='text', data={}, errors={}, classes=[]) %}
@@ -8,6 +29,24 @@
{% endmacro %} +{# +Creates all the markup required for an select element. Handles matching labels to +inputs and error messages. + +name - The name of the form parameter. +id - The id to use on the input and label. Convention is to prefix with 'field-'. +label - The human readable label. +options - A dict of value/label pairs to be used as . +selected - The value of the selected