Editor on preEdit with Condition
Editor on preEdit with Condition
vincmeister
Posts: 136Questions: 36Answers: 4
in Editor
Hello Allan,
Is it possible editor on preEdit with Condition based on other field?
->on( 'preEdit', function ( $editor, $values ) {
$editor
->field( 'act_log.log_status' )
// condition here ->setValue(1);
} )
what i want is:
if Field::inst( 'master_expedition.expedition_name' ),
= a, then field( 'act_log.log_status' )
set to 1,
if Field::inst( 'master_expedition.expedition_name' ),
= b, then field( 'act_log.log_status' )
set to 2
please advise, thank you
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Yes. You have the full set of values being given to you in the
$values
array, you would just access them here. For exampleif ( $values['master_expedition']['expedition_name'] === ... )
Allan
hello Allan,
I got an Illegal string offset 'master_expedition' and Illegal string offset 'expedition_typewhen using this code, please advise, thank you
Are you submitting that value from the client-side? What values are being submitted? The "Network" tab in your browser's console will show you.
Allan
No,
User only edit a
act_log.outgoing_date
then i want to
setValue
ofact_log.log_status
based onmaster_expedition.expedition_type
if
master_expedition.expedition_type
= 'Internal' thenact_log.log_status
= 5else
act_log.log_status
= 6Please help, thank you
Full Editor
That's the issue then. You could submit the other data you require for your logic as a hidden field -
hidden
. Either that or you need to read it from the database.Allan
Thanks for the explanation Allan. I change my condition on client side using editor preOpen and works