Forum

Thread tagged as: Problem, Error

No active select field type

Perch seems to forget which item is active in a select field? Whenever I save changes, the select field is back on the first choice... Is it just me or a general bug? (I use the latest version)

Ken Wuytack

Ken Wuytack 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's most likely you - can you show us your template and diagnostics report?

TEMPLATE: <div class="col-lg-3 col-lg-push-4 col-md-4 col-md-push-4 col-sm-6 col-xs-12"> <h3><perch:content id="title01" type="text" label="Title" required="true" title="true" divider-before="One" /></h3> <perch:content id="text01" type="textarea" label="Text" markdown="false" editor="redactor" required="true" html="true" /> <a href="<perch:content id="link01" type="select" label="Link" options="Home | index.php, Wie is Mahla? | wie-is-mahla.php, Wat doet Mahla? | wat-doet-mahla.php, Rechtstakken | rechtstakken.php, Bemiddeling | bemiddeling.php, Hoe werkt Mahla? | hoe-werkt-mahla.php, Publicaties | publicaties.php, Contact | contact.php" allowempty="false" required="true" />" class="btn">Lees meer</a> </div> <div class="col-lg-3 col-lg-push-5 col-md-4 col-md-push-4 col-sm-6 col-xs-12"> <h3><perch:content id="title02" type="text" label="Title" required="true" title="true" divider-before="Two" /></h3> <perch:content id="text02" type="textarea" label="Text" markdown="false" editor="redactor" required="true" html="true" /> <a href="<perch:content id="link02" type="select" label="Link" options="Home | index.php, Wie is Mahla? | wie-is-mahla.php, Wat doet Mahla? | wat-doet-mahla.php, Rechtstakken | rechtstakken.php, Bemiddeling | bemiddeling.php, Hoe werkt Mahla? | hoe-werkt-mahla.php, Publicaties | publicaties.php, Contact | contact.php" allowempty="false" required="true" />" class="btn">Lees meer</a> </div>

I found the solution. It's because of the blank space between the label, | and the value (in options). I removed it and now perch remembers the active item.

Ken, perch uses php's trim() function on the option value which removes the space in your values. Then when the form is repopulated the saved value does not match any of your options because your options have a space in the value.

So, your solution is the correct one because now your options values have the whitespace removed "trimmed" before.

I know it's easier to see/read your code when you have spaced things out but sometimes these spaces become a real pain.