original_string: public function getValidField($id)
      {
          $objReturn = null;
  
          $objFields = $this->getFields();
          foreach ($objFields as $objField) {
              if ($objField->getId() == $id) {
                  $objReturn = $objField;
                  break;
              }
          }
  
          if (is_null($objReturn)) {
              foreach ($objFields as $objField) {
                  if ($objField->getName() == $id) {
                      $objReturn = $objField;
                      break;
                  }
              }
          }
  
          return $objReturn;
      }
code: public function getValidField($id)
      {
          $objReturn = null;
  
          $objFields = $this->getFields();
          foreach ($objFields as $objField) {
              if ($objField->getId() == $id) {
                  $objReturn = $objField;
                  break;
              }
          }
  
          if (is_null($objReturn)) {
              foreach ($objFields as $objField) {
                  if ($objField->getName() == $id) {
                      $objReturn = $objField;
                      break;
                  }
              }
          }
  
          return $objReturn;
      }
code_tokens: public function getValidField ( $ id ) { $ objReturn = null ; $ objFields = $ this -> getFields ( ) ; foreach ( $ objFields as $ objField ) { if ( $ objField -> getId ( ) == $ id ) { $ objReturn = $ objField ; break ; } } if ( is_null ( $ objReturn ) ) { foreach ( $ objFields as $ objField ) { if ( $ objField -> getName ( ) == $ id ) { $ objReturn = $ objField ; break ; } } } return $ objReturn ; }
docstring: Get a valid field object.
  
  This is about the most important method of ValidForm Builder. Use this to get a valid field after validation
  to fetch it's validated value.
  
  Example:
  ```php
  $objForm = new ValidForm('example');
  
  $objForm->addField('test', 'Test field', ValidForm::VFORM_STRING);
  
  if ($objForm->isSubmitted() && $objForm->isValid()) {
  $strTest = $objForm->getValidField("test")->getValue();
  // $strTest now contains the validated value of the 'test' field which is safe for database storage etc.
  
  $strOutput = "Test value is: " . $strTest;
  } else {
  $strOutput = $objForm->toHtml();
  }
  ```
  @param string $id
  @return Element|null
docstring_tokens: Get a valid field object .