[verb (dictionary form)] + よりほかない [verb (dictionary form)] + よりほかはない [verb (dictionary form)] + よりほかにない [verb (dictionary form)] + よりほかしかたがない
よりほかない follows the dictionary form of a verb and means "there is nothing for it but to": you have looked for another way and found none. ほか is "other", so the phrase reads "there is nothing other than doing it". It belongs to writing and serious speech; in conversation the same thing is しかない.
The verb stays in the dictionary form whatever the tense; the past goes on ない, as in ほかなかった. は or に can go after ほか with no change in meaning: よりほかはない, よりほかにない.