Need help for customer action for form submissions
flylzj opened this issue · 3 comments
Hey guys, I am writeing a feature and meting a problem. here is the situation below, user fill the userinfo form and admin can Review the form and jump to the add acount view. I don't know how and where to add the jump button. I have tried the code below, it only show the text not the html.
class MySubmissions(AbstractFormSubmission):
def get_data(self):
"""
Returns dict with form data.
You can override this method to add additional data.
"""
form_data = super(MySubmissions, self).get_data()
form_data["add_account_href"] = "<button><a href='/admin/users/add?info=xxx'</a></button>"
return form_data
class JoinUsFormPage(CoderedFormPage):
class Meta:
verbose_name = "成为会员表单页"
template = "coderedcms/pages/form_page.html"
def get_submission_class(self):
return MySubmissions
def get_data_fields(self):
"""
Returns a list of tuples with (field_name, field_label).
"""
data_fields = super().get_data_fields() + [("add_account_href", "添加账户")]
return data_fields
Please help me, thank you
@flylzj could the crx html block work for you? https://docs.coderedcorp.com/wagtail-crx/features/blocks/contentblocks/html.html
If not can you share what the template looks like? Instead of putting the html inside the form_data, might be better to store the href and do something like this in the template.
<button><a href="{{ add_account_url }}"></a></button>
where add_account_ url is the /admin/users/add?info=xxx you are storing in form_data
I would recommend adding the account link/href as help text in the form. That can be rendered as html.
If you need a more advanced form, consider using Stream Forms, which allows for mixing form fields and other streamfield block content. https://docs.coderedcorp.com/wagtail-crx/features/page_types/stream_forms.html