I am trying to get a custom field value on entries.onBeforeSaveEntry, event. So I can perform some action depending on the value of that field.

craft()->on('entries.onBeforeSaveEntry', function(Event $event)
    $entry = $event->params['entry'];
    $entry->publishOnMobileApp;  //publishOnMobileApp is the field handle

Now this line.



Craft\MultiOptionsFieldData Object ( 
    [_options:Craft\MultiOptionsFieldData:private] => 
Array ( [0] => Craft\OptionData Object 
    [label] => Yes [value] => yes [selected] => )
   [storage:ArrayObject:private] => Array()

I am not sure how exactly I can access just the value of the field (which is "yes" in this case) so I can perform a check.

1 Answer 1


Please take a look at the docs it's the same in PHP as in Twig

foreach($entry->getFieldValue('publishOnMobileApp')->options as $option){
         // $option->label is selected

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.