english/libraries/joomla/form/form.php
/**
	 * Method to get a form field represented as an XML element 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.
	 *
	 * @return  mixed  The XML element object for the field or boolean false on error.
	 *
	 * @since   11.1
	 */
Method to get a form field represented as an XML element 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.

@return  mixed  The XML element object for the field or boolean false on error.


Method to get a form field represented as an XML element 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 . @return mixed The XML element object for the field or boolean false on error .
protected function findField($name, $group = null)
	{
		$element	= false;
		$fields		= array();
		if (!($this->xml instanceof JXMLElement)) {
			return false;
		}
		if ($group) {
			$elements = & $this->findGroup($group);
			foreach ($elements as $element)
			{
				if ($tmp = $element->xpath('descendant::field[@name="'.$name.'"]')) {
					$fields = array_merge($fields, $tmp);
				}
			}
			if (!$fields) {
				return false;
			}
			$groupNames = explode('.', $group);
			foreach ($fields as & $field)
			{
				$attrs = $field->xpath('ancestor::fields[@name]/@name');
				$names	= array_map('strval', $attrs ? $attrs : array());
				if ($names == (array) $groupNames) {
					$element = & $field;
					break;
				}
			}
		}
		else {
			$fields = $this->xml->xpath('//field[@name="'.$name.'"]');
			if (!$fields) {
				return false;
			}
			foreach ($fields as & $field)
			{
				if ($field->xpath('ancestor::fields[@name]')) {
					continue;
				}
				else {
					$element = & $field;
					break;
				}
			}
		}
		return $element;
	}
protected function findField ( $ name , $ group = null ) { $ element = false ; $ fields = array ( ) ; if ( ! ( $ this -> xml instanceof JXMLElement ) ) { return false ; } if ( $ group ) { $ elements = & $ this -> findGroup ( $ group ) ; foreach ( $ elements as $ element ) { if ( $ tmp = $ element -> xpath ( 'descendant::field[@name="' . $ name . '"]' ) ) { $ fields = array_merge ( $ fields , $ tmp ) ; } } if ( ! $ fields ) { return false ; } $ groupNames = explode ( '.' , $ group ) ; foreach ( $ fields as & $ field ) { $ attrs = $ field -> xpath ( 'ancestor::fields[@name]/@name' ) ; $ names = array_map ( 'strval' , $ attrs ? $ attrs : array ( ) ) ; if ( $ names == ( array ) $ groupNames ) { $ element = & $ field ; break ; } } } else { $ fields = $ this -> xml -> xpath ( '//field[@name="' . $ name . '"]' ) ; if ( ! $ fields ) { return false ; } foreach ( $ fields as & $ field ) { if ( $ field -> xpath ( 'ancestor::fields[@name]' ) ) { continue ; } else { $ element = & $ field ; break ; } } } return $ element ; }
Method to get a form field represented as an XML element object.
Method to get a form field represented as an XML element object .
// Initialise variables. // Make sure there is a valid JForm XML document. // Let's get the appropriate field element based on the method arguments. // Get the fields elements for a given group. // Get all of the field elements with the correct name for the fields elements. // If there are matching field elements add them to the fields array. // Make sure something was found. // Use the first correct match in the given group. // Get the group names as strings for ancestor fields elements. // If the field is in the exact group use it and break out of the loop. // Get an array of fields with the correct name. // Make sure something was found. // Search through the fields for the right one. // If we find an ancestor fields element with a group name then it isn't what we want. // Found it!