Skip to content

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

Open
AhmedBenchekroun wants to merge 2 commits into
HarvestHub:masterfrom
AhmedBenchekroun:bugfix/gh-132
Open

Fixed issue 132: user don't need to choose a plot if there's only one…#156
AhmedBenchekroun wants to merge 2 commits into
HarvestHub:masterfrom
AhmedBenchekroun:bugfix/gh-132

Conversation

@AhmedBenchekroun

Copy link
Copy Markdown

… plot available

@alexgleason alexgleason left a comment

Copy link
Copy Markdown
Contributor

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.

</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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants