src/FieldHandlers/FieldHandler.php
protected function setDefaultValue() : void
    {
        if (empty($this->defaultOptions['default'])) {
            return;
        }

        // If we have a default value from configuration, pass it through
        // processing for magic/dynamic values like dates and usernames.
        $eventName = (string)EventName::FIELD_HANDLER_DEFAULT_VALUE();
        $event = new Event($eventName, $this, [
            'default' => $this->defaultOptions['default']
        ]);

        $view = $this->config->getView();
        $view->getEventManager()->dispatch($event);

        // Only overwrite the default if any events were triggered
        $listeners = $view->getEventManager()->listeners($eventName);
        if (empty($listeners)) {
            return;
        }
        $this->defaultOptions['default'] = $event->result;
    }
protected function setDefaultValue() : void
    {
        if (empty($this->defaultOptions['default'])) {
            return;
        }

        // If we have a default value from configuration, pass it through
        // processing for magic/dynamic values like dates and usernames.
        $eventName = (string)EventName::FIELD_HANDLER_DEFAULT_VALUE();
        $event = new Event($eventName, $this, [
            'default' => $this->defaultOptions['default']
        ]);

        $view = $this->config->getView();
        $view->getEventManager()->dispatch($event);

        // Only overwrite the default if any events were triggered
        $listeners = $view->getEventManager()->listeners($eventName);
        if (empty($listeners)) {
            return;
        }
        $this->defaultOptions['default'] = $event->result;
    }
protected function setDefaultValue ( ) : void { if ( empty ( $ this -> defaultOptions [ 'default' ] ) ) { return ; } // If we have a default value from configuration, pass it through // processing for magic/dynamic values like dates and usernames. $ eventName = ( string ) EventName :: FIELD_HANDLER_DEFAULT_VALUE ( ) ; $ event = new Event ( $ eventName , $ this , [ 'default' => $ this -> defaultOptions [ 'default' ] ] ) ; $ view = $ this -> config -> getView ( ) ; $ view -> getEventManager ( ) -> dispatch ( $ event ) ; // Only overwrite the default if any events were triggered $ listeners = $ view -> getEventManager ( ) -> listeners ( $ eventName ) ; if ( empty ( $ listeners ) ) { return ; } $ this -> defaultOptions [ 'default' ] = $ event -> result ; }
Set default field value

@return void
Set default field value