<p>You could try setting a minimum length:</p>

<pre><code>'fieldName' =&gt;  array(AttributeType::Name, 'minLength' =&gt; 1, 'required' =&gt; true),
</code></pre>

CC BY-SA 3.0
2015-05-22T12:59:28.623Z
cheers @carlcs that worked
Lettie
CC BY-SA 3.0
2015-05-22T12:29:59.727Z
2015-05-22T12:29:59.727Z
carlcs
<p>I have a plugin with record and model both setting required to true for a frontend form entry:</p>

<pre><code>'fieldName' =&gt;  array(AttributeType::Name, 'required' =&gt; true),
</code></pre>

<p>However it is still validating the select option even when there is no value so:</p>

<pre><code>&lt;select id="fieldName" name="fieldName"&gt;
    &lt;option&gt;--select one--&lt;/option&gt;
</code></pre>

<p>or</p>

<pre><code>&lt;option value=''&gt;--select one--&lt;/option&gt;
</code></pre>

<p>Still validates as true.</p>

<p>How can I get around this?</p>

<form><validation>
Select statement validating as true when no value selected?
# Select statement validating as true when no value selected?

(Asked by: username_0 on 2015-05-22)

I have a plugin with record and model both setting required to true for a frontend form entry:
'fieldName' =>  array(AttributeType::Name, 'required' => true),

However it is still validating the select option even when there is no value so:

    --select one--

or
--select one--

Still validates as true.
How can I get around this?

**Tags:** form, validation


---

## 1 answers

### Answer by username_1 on 2015-05-22. Score: 1 | Accepted answer

You could try setting a minimum length:
'fieldName' =>  array(AttributeType::Name, 'minLength' => 1, 'required' => true),

> **Comments:**
> **username_0**: cheers @username_1 that worked  

---

