english/libraries/joomla/application/component/modelform.php
/**
	 * Method to get a form object.
	 *
	 * @param   string   $name     The name of the form.
	 * @param   string   $source   The form source. Can be XML string if file flag is set to false.
	 * @param   array    $options  Optional array of options for the form creation.
	 * @param   boolean  $clear    Optional argument to force load a new form.
	 * @param   string   $xpath    An optional xpath to search for the fields.
	 *
	 * @return  mixed  JForm object on success, False on error.
	 *
	 * @see     JForm
	 * @since   11.1
	 */
Method to get a form object.
@param   string   $name     The name of the form.
@param   string   $source   The form source. Can be XML string if file flag is set to false.
@param   array    $options  Optional array of options for the form creation.
@param   boolean  $clear    Optional argument to force load a new form.
@param   string   $xpath    An optional xpath to search for the fields.

@return  mixed  JForm object on success, False on error.


Method to get a form object . @param string $name The name of the form . @param string $source The form source . Can be XML string if file flag is set to false . @param array $options Optional array of options for the form creation . @param boolean $clear Optional argument to force load a new form . @param string $xpath An optional xpath to search for the fields . @return mixed JForm object on success False on error .
protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false)
	{
		$options['control']	= JArrayHelper::getValue($options, 'control', false);
		$hash = md5($source.serialize($options));
		if (isset($this->_forms[$hash]) && !$clear) {
			return $this->_forms[$hash];
		}
		JForm::addFormPath(JPATH_COMPONENT.'/models/forms');
		JForm::addFieldPath(JPATH_COMPONENT.'/models/fields');
		try {
			$form = JForm::getInstance($name, $source, $options, false, $xpath);
			if (isset($options['load_data']) && $options['load_data']) {
				$data = $this->loadFormData();
			} else {
				$data = array();
			}
			$this->preprocessForm($form, $data);
			$form->bind($data);
		} catch (Exception $e) {
			$this->setError($e->getMessage());
			return false;
		}
		$this->_forms[$hash] = $form;
		return $form;
	}
protected function loadForm ( $ name , $ source = null , $ options = array ( ) , $ clear = false , $ xpath = false ) { $ options [ 'control' ] = JArrayHelper :: getValue ( $ options , 'control' , false ) ; $ hash = md5 ( $ source . serialize ( $ options ) ) ; if ( isset ( $ this -> _forms [ $ hash ] ) && ! $ clear ) { return $ this -> _forms [ $ hash ] ; } JForm :: addFormPath ( JPATH_COMPONENT . '/models/forms' ) ; JForm :: addFieldPath ( JPATH_COMPONENT . '/models/fields' ) ; try { $ form = JForm :: getInstance ( $ name , $ source , $ options , false , $ xpath ) ; if ( isset ( $ options [ 'load_data' ] ) && $ options [ 'load_data' ] ) { $ data = $ this -> loadFormData ( ) ; } else { $ data = array ( ) ; } $ this -> preprocessForm ( $ form , $ data ) ; $ form -> bind ( $ data ) ; } catch ( Exception $ e ) { $ this -> setError ( $ e -> getMessage ( ) ) ; return false ; } $ this -> _forms [ $ hash ] = $ form ; return $ form ; }
Method to get a form object.
Method to get a form object .
// Handle the optional arguments. // Create a signature hash. // Check if we can use a previously loaded form. // Get the form. // Get the data for the form. // Allow for additional modification of the form, and events to be triggered. // We pass the data because plugins may require it. // Load the data into the form after the plugins have operated. // Store the form for later.