src/Contao/View/Contao2BackendView/Subscriber/WidgetBuilder.php
private function valueToWidget(ModelInterface $model, PropertyInterface $property)
    {
        $environment = $this->getEnvironment();

        $event = new DecodePropertyValueForWidgetEvent($environment, $model);
        $event
            ->setProperty($property->getName())
            ->setValue($model->getProperty($property->getName()));

        $environment->getEventDispatcher()->dispatch($event::NAME, $event);
        $value = $event->getValue();

        $propExtra = $property->getExtra();

        if ((0 === (int) $value)
            && \is_numeric($value)
            && empty($propExtra['mandatory'])
            && (isset($propExtra['rgxp']) && \in_array($propExtra['rgxp'], ['date', 'time', 'datim']))
        ) {
            $value = '';
        }

        return $value;
    }
private function valueToWidget(ModelInterface $model, PropertyInterface $property)
    {
        $environment = $this->getEnvironment();

        $event = new DecodePropertyValueForWidgetEvent($environment, $model);
        $event
            ->setProperty($property->getName())
            ->setValue($model->getProperty($property->getName()));

        $environment->getEventDispatcher()->dispatch($event::NAME, $event);
        $value = $event->getValue();

        $propExtra = $property->getExtra();

        if ((0 === (int) $value)
            && \is_numeric($value)
            && empty($propExtra['mandatory'])
            && (isset($propExtra['rgxp']) && \in_array($propExtra['rgxp'], ['date', 'time', 'datim']))
        ) {
            $value = '';
        }

        return $value;
    }
private function valueToWidget ( ModelInterface $ model , PropertyInterface $ property ) { $ environment = $ this -> getEnvironment ( ) ; $ event = new DecodePropertyValueForWidgetEvent ( $ environment , $ model ) ; $ event -> setProperty ( $ property -> getName ( ) ) -> setValue ( $ model -> getProperty ( $ property -> getName ( ) ) ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( $ event :: NAME , $ event ) ; $ value = $ event -> getValue ( ) ; $ propExtra = $ property -> getExtra ( ) ; if ( ( 0 === ( int ) $ value ) && \ is_numeric ( $ value ) && empty ( $ propExtra [ 'mandatory' ] ) && ( isset ( $ propExtra [ 'rgxp' ] ) && \ in_array ( $ propExtra [ 'rgxp' ] , [ 'date' , 'time' , 'datim' ] ) ) ) { $ value = '' ; } return $ value ; }
Decode the value for the widget.

@param ModelInterface    $model    The model.
@param PropertyInterface $property The property name.

@return mixed
Decode the value for the widget .