Editor: Ordering Select option on Value NOT text

Editor: Ordering Select option on Value NOT text

ShaneBrennanShaneBrennan Posts: 23Questions: 7Answers: 1

Hi

I have a form for entering Injury Severity in a H&S form.

The "Table" has 2 fields value and label:

(value) (label)
1 Slight
2 Moderate
3 Significant
4 Intolerable

When I use these in the Editor using:

  Field::inst( 'tblHealthAndSafetyRiskAssessmentHazards.likelihood' )
     ->options(Options::inst()
        ->table( 'tblHandSRALikelihoodLabels')
        ->value( 'value' )
        ->label( 'Label' )
     )
     ->validator( 'Validate::dbValues' )  

I get the list as

Intolerable
Moderate
Significant
Slight
/
This is obviously incorrect - is there a way of ordering the list by "value"?

I know I could change the labels to:

  1. Slight
  2. Moderate
  3. Significant
  4. Intolerable

But that's just pants

Thank you very much for any advice given.

This question has an accepted answers - jump to answer

Answers

  • ShaneBrennanShaneBrennan Posts: 23Questions: 7Answers: 1
    edited July 16

    Forget it - PICNIC Error!!

    Problem In Chair Not In Computer - 10 seconds after posting I had a brain wave and it worked - just use the option ORDER!:

      Field::inst( 'tblHealthAndSafetyRiskAssessmentHazards.likelihood' )
         ->options(Options::inst()
            ->table( 'tblHandSRALikelihoodLabels')
            ->value( 'value' )
            ->label( 'label' )
            ->order( 'value asc')
    

    Silly me !

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin
    Answer ✓

    Brilliant! I haven't seen that acronym before. Love it.

    Nice one finding the solution as well :). Looks perfect to me (and it is designed that way, that's not a fluke that it works).

    Allan

Sign In or Register to comment.