0

I am having issues with an entry form that updates current entries.

I have a field called "Driver Type" and its handle is "driverType". It is set as a drop-down field on the admin panel. When I submit the form with a driver type selected I will get the following error saying "Driver Type is invalid.".

I find this very odd because I also have a dropdown field called "Minimum Age Requirement" with the handle "minimumAgeRequirement" that updates correctly when I submit the form. The form will not submit when the"driver type" field is in there, but When i remove "driver type" everything else works perfectly fine.

I am identically rendering both fields and mapping them to their respective fields.

driver type

  <div class="form-group">
    <label for="driverType">Driver Type</label>
    {% set drivers = craft.app.fields.getFieldByHandle('driverType') %}
    <select class="form-control" name="fields[driverType]" id="driverType">
      <option value="none" selected>Select a Driver Type</option>
       {% for option in drivers.options %}
      {% if option.label == entry.driverType.label %}
      <option value="{{option.value}}" selected>{{option.label}}</option>
      {% endif %}
      <option value="{{option.value}}">{{option.label}}</option>
      {% endfor %}   
    </select>
  </div>

Minimum Age Requirement

<div class=" form-group">
    <label for="minimumAgeRequirement">Minimum Age Requirement</label>
    {% set minimumAgeRequirement = craft.app.fields.getFieldByHandle('minimumAgeRequirement') %}
    <select class="form-control" name="fields[minimumAgeRequirement]" id="minimumAgeRequirement">
      <option value="none" selected>Select</option>
      {% for option in minimumAgeRequirement.options %}
      {% if option.label == entry.minimumAgeRequirement.label %}
      <option value="{{option.value}}" selected>{{option.label}}</option>
      {% endif %}
      <option value="{{option.value}}">{{option.label}}</option>
      {% endfor %}
    </select>
  </div>

What I don't understand or at least have a hard time comprehending is why I am seeing the following error in the weblogs regarding the driver type field. Below is is the error message I see in the web log

2020-09-17 17:05:50 [-][1][-][info][craft\services\Elements::_saveElementInternal] Element not saved due to validation error: Array
(
    [driverType] => Array
        (
            [0] => Driver Type is invalid.
        )

)

If both fields are drop-down fields, why isn't "driver type" receiving the same error? Any help would be greatly appreciated...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.