Field.setValue based on the value of other fields.
Field.setValue based on the value of other fields.
clazette
Posts: 26Questions: 7Answers: 2
I want to set the name field's value based on the value of fields last_name and first_name. I have tried the source field's getValue function but I receive a call to undefined function fatal error. The Editor documentation lists getValue as an existing function, and the method exists in Field.php, for a field instance. Clearly, I am doing something incorrectly. What am I missing?
Field::inst( 'name' )
->set( Field::SET_BOTH ) // Do this for create and edit.
->setValue(Field::inst( 'last_name' ).getValue()),
This discussion has been closed.
Answers
Well, this appears to work although, at this point, I'm not exactly sure why.
Did you ever get an answer to this? It's strange that setFormatter would work and getValue returns undefined function.
There are two options to do what clazette wants:
setFormatter
to get the values of the other fields as the second post suggestsAllan