This proof isn't correct.
You have the right idea, your maps lift to a map $\phi\colon Y \to X$ and you need to prove that the image of $\phi$ is actually contained in $P$. Then you have your lift $\phi\colon Y \to P$ which is unique because any lift to a map $Y \to X$ is unique.
The problem with the proof is in proving that $\phi\colon Y \to X$ has image in $P$. You use the equation $Y = \bigcup_iY_i$ which you think follows from the fact that the $Y_i$ cover $Y$, but remember these are functors and in this functorial approach the definition of a cover is that $Y(k) = \bigcup_iY_i(k)$ whenever $k$ is a field. For an arbitrary ring $B$ the equation $Y(B) = \bigcup_iY_i(B)$ need not hold. If it did hold then every functor would be local because we can glue maps in the category of sets.
As for how to fix it? I see you are assuming that $Y$ is an affine scheme, so $Y = \hom(A, -)$, if you can also assume that the $Y_i$ are of the form $D(x_i)$ for $x_i \in A$ (which, btw, is how local functors are defined in Demazure and Gabriel) then by Yoneda the localization sequence becomes
$$X(A) \to \prod_iX(A_{x_i}) \rightrightarrows \prod_{ij}X(A_{x_ix_j})$$
Then to show that $P$ is local you need to show that if $x \in X(A)$ maps to $P(A_{x_i})$ for each $i$ then $x \in P(A)$. You do this by first proving the following lemma:
Lemma: Let $P \subseteq X$ be $R$-functors. Then $P$ is open if and only if for every element $x \in X(A)$ there exists an ideal $\mathfrak a_x \leq A$ such that for all $R$-algebra maps $f\colon A \to S$ the induced map $X(f)\colon X(A) \to X(S)$ sends $x$ into $P(S)$ if and only if $Sf(\mathfrak a_x) = S$.
and then showing that $\mathfrak a_x = A$ because $x$ mapping to $P(A_{x_i})$ for each $i$ means $\mathfrak a_xA_{x_i} = A_{x_i}$ for all $i$, hence $x_i \in \mathfrak a_x$ for all $i$.
Unfortunately I don't know how to extend from affine open subfunctors to arbitrary open subfunctors. I have that question myself.