/**
* Method to get a form field represented as a FormField object.
*
* @param string $name The name of the form field.
* @param string $group The optional dot-separated form group path on which to find the field.
* @param mixed $value The optional value to use as the default for the field.
*
* @return FormField|boolean The FormField object for the field or boolean false on error.
*
* @since 1.7.0
*/
public function getField($name, $group = null, $value = null)
{
// Make sure there is a valid Form XML document.
if (!$this->xml instanceof \SimpleXMLElement) {
throw new \UnexpectedValueException(sprintf('%s::%s `xml` is not an instance of SimpleXMLElement', \get_class($this), __METHOD__));
}
// Attempt to find the field by name and group.
$element = $this->findField($name, $group);
// If the field element was not found return false.
if (!$element) {
return false;
}
return $this->loadField($element, $group, $value);
}