Editor - Ensuring unique values on "New" and "Edit" screens/forms.

Editor - Ensuring unique values on "New" and "Edit" screens/forms.

brennan119brennan119 Posts: 5Questions: 3Answers: 0

I'm very new to editor and datatables, but have successfully got a working screen to maintain a list of Statuses, just 1 column - (field name called Status). Adding, deleting, etc is working fine...

What I need to do is stop/prevent someone entering the same status twice... basically ensure the list is unique and through the "New" & "Edit" buttons - prevent it from being saved back to the MSSQL backend database.

ideally also check when they click on the cell and edit it there - but that's a lot of hoping :smiley:

Again thank you in advance for any help you can give me.

Answers

  • brennan119brennan119 Posts: 5Questions: 3Answers: 0
    edited December 2016

    Sorry, jumped the gun - I found the answer 20 seconds after posting - sorry. The solution was to use the "unique" validator:

    Editor::inst( $db, 'tblStatus )
        ->fields(
            Field::inst( 'status' )
             ->validator( 'Validate::notEmpty' )
             ->validator( 'Validate:unique') 
            
        )
        ->process( $_POST )
        ->json();
    

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,834Questions: 1Answers: 10,518 Site admin

    Thanks for posting back. Great to hear you've found the answer.

    Allan

This discussion has been closed.