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

Styled file field with materializecss template filter #3998

Merged
merged 2 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Add settings to enable Django Debug Toolbar - #3983 by @koradon
- Implement variant availability, introducing discounts in variants - #3948 by @NyanKiyoshi
- Add bulk actions - #3955 by @dominik-zeglen
- Update file field styles with materializecss template filter - #3998 by @zodiacfireworks


## 2.5.0
Expand Down
67 changes: 57 additions & 10 deletions templates/materializecssform/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,66 @@
{% endif %}
</div>
{% elif field|is_file %}
<div class="input col {{ classes.label }}">
<div
class="input col input-field {{ classes.label }}">
{% if field.auto_id %}
<p>
{% if field.auto_id %}
<label class="{{ classes.label }}" for="{{ field.auto_id }}">
{{ field.label }}
{% if not field.field.required %}
{% trans "(optional)" context "Dashboard form labels" %}
<label
class="{{ classes.label }}"
for="{{ field.auto_id }}">
{{ field.label }}
{% if not field.field.required %}
{% trans "(optional)" context "Dashboard form labels" %}
{% endif %}
</label>
</p>
{% endif %}

{% with field.field.widget as widget %}
{% if field.value %}
<p>
{{ widget.initial_text }}:
<a
href="{{ field.value.url }}">
{{ field.value }}
</a>
{% if not widget.required %}
<input
type="checkbox"
name="{{ field.name }}-clear"
id="{{ field.name }}-clear_id">
<label
for="{{ field.name }}-clear_id">
{{ widget.clear_checkbox_label }}
</label>
{% endif %}
</label>
<br>
</p>
{% endif %}
{{ field }}
</p>
{% endwith %}

<div class="file-field">
<p>
<div class="btn">
<span>
{% trans "File" %}
</span>
<input class="file-chooser" id="{{ field.auto_id }}" name="{{ field.name }}" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path" type="text">
</div>
</p>
{% for error in field.errors %}
<p class="help-block materialize-red-text">
{{ error }}
</p>
{% endfor %}
{% if field.help_text %}
<p class="help-block">
{{ field.help_text|safe }}
</p>
{% endif %}
</div>
</div>
{% elif field|is_versatile_image_ppoi_click_widget %}
<div class="input col file-field input-field {{ classes.label }}">
Expand Down