public function view( $fields = null ) {

		$pod =& $this;

		// Convert comma separated list of fields to an array.
		if ( null !== $fields && ! is_array( $fields ) && 0 < strlen( $fields ) ) {
			$fields = explode( ',', $fields );
		}

		$object_fields = (array) pods_v( 'object_fields', $this->pod_data, array(), true );

		if ( empty( $fields ) ) {
			// Add core object fields if $fields is empty.
			$fields = array_merge( $object_fields, $this->fields );
		}

		// Temporary.
		$view_fields = $fields;

		$fields = array();

		foreach ( $view_fields as $name => $field ) {
			$defaults = array(
				'name' => $name,
			);

			if ( ! is_array( $field ) ) {
				$name = $field;

				$field = array(
					'name' => $name,
				);
			}

			// @codingStandardsIgnoreLine.
			$field = array_merge( $defaults, $field );

			$field['name'] = trim( $field['name'] );

			if ( empty( $field['name'] ) ) {
				$field['name'] = trim( $name );
			}

			if ( isset( $object_fields[ $field['name'] ] ) ) {
				// @codingStandardsIgnoreLine.
				$field = array_merge( $field, $object_fields[ $field['name'] ] );
			} elseif ( isset( $this->fields[ $field['name'] ] ) ) {
				// @codingStandardsIgnoreLine.
				$field = array_merge( $this->fields[ $field['name'] ], $field );
			}

			if ( pods_v( 'hidden', $field, false, true ) || 'hidden' === $field['type'] ) {
				continue;
			} elseif ( ! PodsForm::permission( $field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id() ) ) {
				continue;
			}

			$fields[ $field['name'] ] = $field;
		}//end foreach

		// Cleanup.
		unset( $view_fields );

		$output = pods_view( PODS_DIR . 'ui/front/view.php', compact( array_keys( get_defined_vars() ) ), false, 'cache', true );

		return $this->do_hook( 'view', $output, $fields, $this->id() );

	}