using isset instead of in_array and move check of $this->preferFormInputFilter outside the foreach the $elements