english/libraries/joomla/form/form.php
/**
	 * Method to load, setup and return a JFormField object based on field data.
	 *
	 * @param   string  $element  The XML element object representation 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  mixed  The JFormField object for the field or boolean false on error.
	 *
	 * @since   11.1
	 */
Method to load, setup and return a JFormField object based on field data.
@param   string  $element  The XML element object representation 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  mixed  The JFormField object for the field or boolean false on error.


Method to load setup and return a JFormField object based on field data . @param string $element The XML element object representation 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 mixed The JFormField object for the field or boolean false on error .
protected function loadField($element, $group = null, $value = null)
	{
		if (!($element instanceof JXMLElement)) {
			return false;
		}
		$type = $element['type'] ? (string) $element['type'] : 'text';
		$field = $this->loadFieldType($type);
		if ($field === false) {
			$field = $this->loadFieldType('text');
		}
		if ($value === null) {
			$default = (string) $element['default'];
			if (($translate = $element['translate_default']) && ((string)$translate=='true' || (string)$translate=='1' ))
			{
				$lang = JFactory::getLanguage();
				if ($lang->hasKey($default))
				{
					$debug = $lang->setDebug(false);
					$default = JText::_($default);
					$lang->setDebug($debug);
				}
				else
				{
					$default = JText::_($default);
				}
			}
			$value = $this->getValue((string) $element['name'], $group, $default);
		}
		$field->setForm($this);
		if ($field->setup($element, $value, $group)) {
			return $field;
		}
		else {
			return false;
		}
	}
protected function loadField ( $ element , $ group = null , $ value = null ) { if ( ! ( $ element instanceof JXMLElement ) ) { return false ; } $ type = $ element [ 'type' ] ? ( string ) $ element [ 'type' ] : 'text' ; $ field = $ this -> loadFieldType ( $ type ) ; if ( $ field === false ) { $ field = $ this -> loadFieldType ( 'text' ) ; } if ( $ value === null ) { $ default = ( string ) $ element [ 'default' ] ; if ( ( $ translate = $ element [ 'translate_default' ] ) && ( ( string ) $ translate == 'true' || ( string ) $ translate == '1' ) ) { $ lang = JFactory :: getLanguage ( ) ; if ( $ lang -> hasKey ( $ default ) ) { $ debug = $ lang -> setDebug ( false ) ; $ default = JText :: _ ( $ default ) ; $ lang -> setDebug ( $ debug ) ; } else { $ default = JText :: _ ( $ default ) ; } } $ value = $ this -> getValue ( ( string ) $ element [ 'name' ] , $ group , $ default ) ; } $ field -> setForm ( $ this ) ; if ( $ field -> setup ( $ element , $ value , $ group ) ) { return $ field ; } else { return false ; } }
Method to load, setup and return a JFormField object based on field data.
Method to load setup and return a JFormField object based on field data .
// Make sure there is a valid JXMLElement. // Get the field type. // Load the JFormField object for the field. // If the object could not be loaded, get a text field object. // Get the value for the form field if not set. // Default to the translated version of the 'default' attribute // if 'translate_default' attribute if set to 'true' or '1' // else the value of the 'default' attribute for the field. // Setup the JFormField object.