No - the law is correct.
Political parties are private entities and have total control over whom they can support as a candidate (or not as the case maybe)
If what you say about it being private, there need never be a law.
A law makes it a public issue.