Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Form Field Select Disabled Option with Required Placeholder Issues

Started by Steven Crichton 8 years ago · 2 replies · 860 views
8 years ago

Hi,

I've been going through the docs. However I have had no luck in creating a disabled option in the form

The field config is as follows::

name: enquiry_type
id: enquiry_type
label: Type of enquiry
type: select
style: vertical
placeholder: --select an item --
validate:
required: true
options:
action: nochoice
folder: achoice
title: thechoice
date: mychoice

This should render according to what I read with the ' -- select an item --' selected and being a disabled option. Thus requiring a user to select an option to make sure the required value is set.

However, when displayed it will always show the first item "nochoice"

Any assistance with this would be greatly appreciated as it seems that the form documentation for simple things like this does not match up with the way the plugin actually operates

Steven

8 years ago

I will also add. ID / classes do not work either.

The form is utilised in a modular page.

the output is as follows::

HTML
<div class="form-field">
    <label class="control-label col-sm-2">
                        How did you hear about us
                        <span class="required">*</span>
    </label>
    <div class="col-sm-10">
        <select class="form-control" name="data[heard_from]" required="required">
                        <option value="placeholder">
                --select an item --
            </option>
                        <option value="action">
                nochoice
            </option>
                        <option value="folder">
                achoice
            </option>
                        <option value="title">
                thechoice
            </option>
                        <option value="date">
                mychoice
            </option>
                    </select>
    </div>
</div>
7 years ago

Hi,

I'm facing the same problem and wonder if there is a solution or a workaround to deal with it.

For instance, I have a form with a select input and I defined a placeholder. The placeholder is never showed (Firefox), the box always displays the first option available.

Plus, even if this select field is marked as required, if I submit the form without touching this field, the form is submitted successfully but I don't receive the corresponding value in the email...

Does anyone have an idea?

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1140 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago