(CNN) A federal judge in California blocked a state law that requires candidates for president to disclose income tax returns before their names can appear on the state's primary ballot.

The ruling is a win for President Donald Trump, who is resisting efforts to turn over his tax returns in a battle largely playing out in the courts.

US District Judge Morrison C. England Jr. of the Eastern District of California on Tuesday wrote "while this Court understands and empathizes with the motivations that prompted California" to pass the law, "the Act's provisions likely violate the Constitution and the laws of the United States." England noted that it is not the court's role "to decide whether a tax return disclosure requirement is good policy or makes political sense."

The judge said the law would set a dangerous precedent and become a slippery slope for other kinds of disclosures. He also said it presents a "troubling minefield " that would permit a state to make its own demands.

Last month -- ruling from the bench -- England, a George W. Bush appointee, signaled he was inclined to rule in favor of Trump.

Read More