Forum

Thread tagged as: Question

Breaking Up Select Input

Hi,

I have a <perch:content type="select" which is going to have quite a few options in it, and I would like to break it up somehow. Is there a way I can use <optgroup> in Perch? Or set some disabled options to use as section headers perhaps? At the moment I am looking at using blank options to give some sort of breaks but can't provide any headers this way. It is a long list of colours so looking to split into "Greens", "Blues" etc.

Thanks!

Mike

Mike Harrison

Mike Harrison 37 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

In 2.8.14 you'll be able to add disabled items, but not opt groups yet.

Cool will sit tight for 2.8.14 as that will be fine for this. Cheers Drew

FWIW I used this for now, but it doesn't stop the user selecting it as an option:

<perch:content id="case-colour" type="select" label="Case Colour" help="This is the main colour of the clock case" options="  Antique White,
           Linen White,
           Pebble White,
           ──────────,
           Antique Cream,
           Cream,
           Gorgeous Cream,
           Sponge Cake Cream,
           ──────────,
           Antique Red,
           Biscuit Box Red,
           Cinema Red,
           Fire Engine Red,
           Flame Red,
           Red,
           ──────────,
           Green,
           Kettle Green,
           Lime Green,
           Mint Ice Cream,
           Vibrant Green,
           ──────────,
           Antique Blue,
           Aqua Blue,
           Blue,
           Cinema Blue,
           Duck Egg,
           Egg Blue,
           Kettle Blue,
           Puddle Blue,
           Sleepy Blue,
           ──────────,
           Pumpkin Orange,
           ──────────,
           Purple Pie,
           ──────────,
           Dreamy Pink,
           Hot Pink,
           ──────────,
           Citrus Yellow,
           Yellow,
           ──────────,
           Black,
           Cave Black,
           Ebony Black,
           ──────────,
           Cinema Grey,
           Clockwork Grey,
           Grey,
           Ice Grey,
           Overcoat Grey,
           Posh Grey,
           ──────────,
           Bean Brown,
           ──────────,
           Chrome,
           Brass,
           ──────────,
           Dark Wood" 
required="true" />

Michael. If you add a pipe to the options you don't want selected and make the field required then it will show error when submitted because it will be an empty post. Just one of my little tricks

<perch:input id="selector" type="select" label="Select One" options="NoValue|,Value|not blank" required="true" />

I typed that on my iPhone. Beware there could be errors.

Thanks Robert I will give that a go

Has this been implemented and if so how to use it? A disabled (first option) is perfect in place of a form label in some circumstances.

Thanks Chris