code: public function setElementRequired(\Zend\Form\Element $element) {
          $element->setAttribute('required', 'true'); //set browser validation
          $this->form->getInputFilter()->get($element->getAttribute('name'))->setAllowEmpty(false); //set backend requirement
      }
docs: Set element required
  frontend & backend validation
  @param \Zend\Form\Element $element