Beispiel #1
0
def build_url_form(url):
    """
    Builds a url parameter form from the given url.
    """
    form_fields = SortedDict()
    url_parameters = tokenize_url_parameters(url)
    for token, parameter in url_parameters:
        form_fields["url-parameter-%s" % parameter] = forms.CharField(
            label=parameter, widget=forms.TextInput(attrs={"required": "required", "data-token": token})
        )

    return type("URLParameterForm", (forms.Form,), form_fields)
Beispiel #2
0
def build_url_form(url):
    """
    Builds a url parameter form from the given url.
    """
    form_fields = SortedDict()
    url_parameters = tokenize_url_parameters(url)
    for token, parameter in url_parameters:
        form_fields["url-parameter-%s" % parameter] = forms.CharField(
            label=parameter,
            widget=forms.TextInput(attrs={
                "required": "required",
                "data-token": token,
            }))

    return type("URLParameterForm", (forms.Form, ), form_fields)