src/properties/class-papi-property-module.php
public function format_value( $value, $slug, $post_id ) {
		if ( is_numeric( $value ) && intval( $value ) !== 0 ) {
			$value = [
				'module'   => get_post( $value ),
				'template' => papi_data_get( $post_id, sprintf( '%s_template', unpapify( $this->html_name() ) ) )
			];

			if ( papi_is_admin() ) {
				return (object) $value;
			}

			// Return the template value instead of index when not in admin.
			if ( $value['module'] instanceof WP_Post ) {
				$templates = $this->get_templates( $value['module']->ID );

				// Check if index exists.
				if ( isset( $templates[$value['template']] ) ) {
					$value['template'] = $templates[$value['template']];
				}

				// Supports label and template array.
				if ( is_array( $value['template'] ) && isset( $value['template']['template'] ) ) {
					$value['template'] = $value['template']['template'];
				}
			}

			return (object) $value;
		}

		return (object) $this->default_value;
	}
public function format_value( $value, $slug, $post_id ) {
		if ( is_numeric( $value ) && intval( $value ) !== 0 ) {
			$value = [
				'module'   => get_post( $value ),
				'template' => papi_data_get( $post_id, sprintf( '%s_template', unpapify( $this->html_name() ) ) )
			];

			if ( papi_is_admin() ) {
				return (object) $value;
			}

			// Return the template value instead of index when not in admin.
			if ( $value['module'] instanceof WP_Post ) {
				$templates = $this->get_templates( $value['module']->ID );

				// Check if index exists.
				if ( isset( $templates[$value['template']] ) ) {
					$value['template'] = $templates[$value['template']];
				}

				// Supports label and template array.
				if ( is_array( $value['template'] ) && isset( $value['template']['template'] ) ) {
					$value['template'] = $value['template']['template'];
				}
			}

			return (object) $value;
		}

		return (object) $this->default_value;
	}
Format the value of the property before it's returned
to WordPress admin or the site.

@param  mixed  $value
@param  string $slug
@param  int    $post_id

@return array