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

Fixed issue 132: user don't need to choose a plot if there's only one… #156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AhmedBenchekroun
Copy link

… plot available

Copy link
Contributor

@alexgleason alexgleason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Please indent the conditionals with 4 spaces. Am about to test it.

@@ -18,9 +18,13 @@
Select a Plot
</div>
<div class="menu">
{% if form.plot.field.queryset.count == 1 %}
<div class="item" data-value="{{ plot.id }}">{{ form.plot.field.queryset.0.title}}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent

{% for plot in form.plot.field.queryset %}
<div class="item" data-value="{{ plot.id }}">{{ plot }}</div>
{% endfor%}
{%endif%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include spaces around endif

@alexgleason
Copy link
Contributor

You are so close, however the form isn't submitting (see screenshot). I'm wondering if you also need to pass the data into value="" or if there's a different way to force the first item to be selected.

screen shot 2018-05-06 at 20 19 14

<div class="item" data-value="{{ plot.id }}">{{ plot }}</div>
{% endfor%}
{% if form.plot.field.queryset.count == 1 %}
<div class="item" data-value="{{ plot.id }}">{{ form.plot.field.queryset.0.title}}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here plot is not set. It's only set in the next part because it's within the for loop, so you need to set the data-value similar to how you're creating the title.

@alexgleason
Copy link
Contributor

So we don't forget, we discovered in our search that adding value="<something>" to the hidden input field for a Semantic UI dropdown will cause it to be set upon page load.

Therefore, we can set the value as the first item in the list under the condition that the list contains multiple items.

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

Successfully merging this pull request may close these issues.

None yet

2 participants