preEdit - How to reference field when using JOIN?

preEdit - How to reference field when using JOIN?

mxyoungmxyoung Posts: 4Questions: 2Answers: 0

Hello,

Using Editor, I have a JOIN, and am trying to use preEdit. I keep getting "Undefined Index" errors on the server.

...
        Field::inst( 'people.id' ),
        Field::inst( 'people.role' ),
        Field::inst( 'users.username' ),
        Field::inst( 'users.passwd' ),
...
->on( 'preEdit', function ( $editor, $id, $values ) {
            $editor           
                ->field('users.passwd')
                ->setValue( sha1($values['passwd']) );
    } )

Line 10 above gives me the error "Undefined index: passwd". I have tried $values['users']['passwd'], and get the same error. I also tried $values[users.password], but get "Illegal string offset 'users.password'" when I do it that way.

Answers

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    $values['users']['passwd'] should do it, but you say you've tried that already. Are you sure it is being submitted from the client-side? Can you show me the data from the browser's network inspector that is being submitted to the server please?

    Allan

  • mxyoungmxyoung Posts: 4Questions: 2Answers: 0

    I had checked the browser inspector and verified the field was being sent, etc. But I had missed a small detail that was the root of the problem.

    ...
            fields: [ {
                    label: "Password",
                    name: "users.password",
    ...
    

    The field was being sent as $values['users']['password'] instead of passwd, because I had named it "password".

    Thanks for the reply.

    Michael

This discussion has been closed.