Psionman
Psionman

Reputation: 3699

How can I change the submit button text on a form created with Django AbstractEmailForm class

I have a form that I have created based on the wagtail documentation.

This does not expose a submit button and is obviously using some default value.

class FoodDiaryPage(AbstractEmailForm):
    template = "food_diary/food_diary_form.html"
    intro = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    content_panels = AbstractEmailForm.content_panels + [
        FieldPanel('intro', classname="full"),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]

No button appears in the template:

{% extends "base.html" %}

{% load wagtailcore_tags %}

{% block content %}
    <h1>{{ page.title }}</h1>
    <p> {{self.intro|richtext }}</p>

    <form action="{% pageurl page %}" method="POST">
        {% csrf_token %}
        <table border="0">
            {% for field in form.visible_fields %}
            <tr>
                <th>{{ field.label_tag }}</th>
                <td>
                    {{ field.errors }}
                    {{ field }}
                    <br>
                    {{ field.help_text }}
                </td>
            </tr>
            {% endfor %}
        </table>
        <input type="submit">
    </form>

{% endblock %}

How can I change the submit button text from 'Submit Query'?

Upvotes: 3

Views: 2258

Answers (1)

Psionman
Psionman

Reputation: 3699

Thanks to RajaSimon, all that is needed is to add a value attribute to the input tag:

<input type="submit" value="Send now">

Upvotes: 2

Related Questions