(a) Before or during trial a plea of guilty may be accepted when:
(1) The defendant enters a plea of guilty in open court;
(2) The court has informed the defendant of the consequences of his plea and of the maximum penalty provided by law which may be imposed upon acceptance of such plea.
Upon acceptance of a plea of guilty the court shall determine the factual basis for the plea.