Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form message class issue #469

Closed
NicoHood opened this issue Jan 2, 2021 · 4 comments
Closed

Form message class issue #469

NicoHood opened this issue Jan 2, 2021 · 4 comments

Comments

@NicoHood
Copy link
Contributor

NicoHood commented Jan 2, 2021

When adding a form message there is an issue with its scope vs type. The message is shown in black instead of green:

<div class="toast toast- success">
            <i class="icon dripicons-"></i> Vielen Dank für deine Bewertung! Wir haben dir soeben eine Bestätigungsemail gesendet. Um deine Bewertung auf der Website anzuzeigen, klicke bitte auf den Bestätigungslink in der E-Mail.
        </div>

This is my messages.html.twig:

{% set type_mapping = {'info':'success', 'error': 'error', 'warning': 'warning'} %}
{% set icon_mapping = {'info':'checkmark', 'error':'wrong', 'warning':'information'} %}

{% if grav.messages.all %}
    <div id="messages">
    {% for message in grav.messages.fetch %}

        {% set scope = message.scope|e %}
        {% set type = type_mapping[scope] %}
        {% set icon = icon_mapping[scope] %}

        <div class="toast toast-{{ type }} {{ scope }}">
            <i class="icon dripicons-{{ icon }}"></i> {{ message.message|raw }}
        </div>
    {% endfor %}
    </div>
{% endif %}

For "normal" messages added via plugin this works fine. The correct html would be <div class="toast toast-success"> (without space). This is NOT a whitespace issue, for some reason type and scope seem to be switched.

Edit: It is possible that this is a quark theme template issue. Maybe success is a valid scope, but quark does not implement it. Also the icons are broken by the way...

@NicoHood
Copy link
Contributor Author

NicoHood commented Jan 2, 2021

I found that the following line is causing the issue:
https://github.com/getgrav/grav-plugin-form/blob/develop/form.php#L495

Is success a valid message type? If not, it must be info. As stated here the message API really needs some more documentation.

@rhukster
Copy link
Member

rhukster commented Jan 4, 2021

It's a hold over from when we had the Antimatter theme that did use the success class. Really this is why it's not good to have any CSS reliance on themes. The current implementation of the form plugin has a fair bit of backward-compatibility complexity. I can't improve things too much because it has the potential of breaking currently installed sites that assume the form functionality (and templates) are going to be compatible when updated.

This is something I plan on revamping completely in Form2 plugin.

@rhukster rhukster closed this as completed Jan 4, 2021
@NicoHood
Copy link
Contributor Author

NicoHood commented Jan 5, 2021

Alright, so you would not fix the code but rather the theme? I can prepare a quark pull request, if you wish.

@mahagr
Copy link
Member

mahagr commented Jan 8, 2021

The code cannot be changed as it breaks existing sites which all assume the current behavior. The fix needs to be in the theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants