Hook that loads the form data from $_POST or the model

Or from whatever other source you specify here.
978466
protected function loadFormData()
    {
        parent::loadFormData();

        // feature request #200
        if (isset($this->formData['gtr_organizations']) && (! is_array($this->formData['gtr_organizations']))) {
            $this->formData['gtr_organizations'] = explode('|', trim($this->formData['gtr_organizations'], '|'));
        }
    }
685266
def is_form_get(attr, attrs):
    """"""
    res = False
    if attr == "action":
        method = attrs.get_true('method', u'').lower()
        res = method != 'post'
    return res
153154
private function postData()
    {
        if (empty($this->post)) {
            return;
        }

        $post = array_filter($this->post);

        return http_build_query($post);
    }
908482
protected function getInput()
	{
		// Get the client id.
		$clientId = $this->element['client_id'];

		if (is_null($clientId) && $this->form instanceof Form)
		{
			$clientId = $this->form->getValue('client_id');
		}
		$clientId = (int) $clientId;

		$client = ClientManager::client($clientId);

		// Get the module.
		$module = (string) $this->element['module'];

		if (empty($module) && ($this->form instanceof Form))
		{
			$module = $this->form->getValue('module');
		}

		$module = preg_replace('#\W#', '', $module);

		// Get the template.
		$template = (string) $this->element['template'];
		$template = preg_replace('#\W#', '', $template);

		// Get the style.
		if ($this->form instanceof Form)
		{
			$template_style_id = $this->form->getValue('template_style_id');
		}

		$template_style_id = preg_replace('#\W#', '', $template_style_id);

		// If an extension and view are present build the options.
		if ($module && $client)
		{

			// Load language file
			$lang = App::get('language');
				$lang->load($module . '.sys', PATH_APP . '/modules/' . $module, null, false, true)
			||	$lang->load($module . '.sys', PATH_CORE . '/modules/' . $module, null, false, true);

			// Get the database object and a new query object.
			$db = App::get('db');

			// Build the query.
			$query = $db->getQuery()
				->select('e.element')
				->select('e.name')
				->from('#__extensions', 'e')
				->whereEquals('e.client_id', (int) $clientId)
				->whereEquals('e.type', 'template')
				->whereEquals('e.enabled', '1');

			if ($template)
			{
				$query->whereEquals('e.element', $template);
			}

			if ($template_style_id)
			{
				$query
					->join('#__template_styles as s', 's.template', 'e.element', 'left')
					->whereEquals('s.id', (int) $template_style_id);
			}

			// Set the query and load the templates.
			$db->setQuery($query->toString());
			$templates = $db->loadObjectList('element');

			// Check for a database error.
			if ($db->getErrorNum())
			{
				App::abort(500, $db->getErrorMsg());
			}

			$paths = array(PATH_APP, PATH_CORE);

			foreach ($paths as $path)
			{
				if (is_dir($path . '/modules/' . $module))
				{
					break;
				}
			}

			// Build the search paths for module layouts.
			$module_path = Util::normalizePath($path . '/modules/' . $module . '/tmpl');

			// Prepare array of component layouts
			$module_layouts = array();

			// Prepare the grouped list
			$groups = array();

			// Add the layout options from the module path.
			if (is_dir($module_path) && ($module_layouts = App::get('filesystem')->files($module_path, '^[^_]*\.php$')))
			{
				// Create the group for the module
				$groups['_'] = array();
				$groups['_']['id'] = $this->id . '__';
				$groups['_']['text'] = $lang->txt('JOPTION_FROM_MODULE');
				$groups['_']['items'] = array();

				foreach ($module_layouts as $file)
				{
					// Add an option to the module group
					$value = App::get('filesystem')->name(ltrim($file, DIRECTORY_SEPARATOR));
					$text = $lang->hasKey($key = strtoupper($module . '_LAYOUT_' . $value)) ? $lang->txt($key) : $value;
					$groups['_']['items'][] = Dropdown::option('_:' . $value, $text);
				}
			}

			// Loop on all templates
			if ($templates)
			{
				foreach ($templates as $template)
				{
					$template->path = '';

					foreach ($paths as $p)
					{
						if (is_dir($p . '/templates/' . $template->element))
						{
							$template->path = $p . '/templates/' . $template->element;
							break;
						}
					}

					if (!$template->path)
					{
						continue;
					}

					// Load language file
					$lang->load('tpl_' . $template->element . '.sys', $template->path, null, false, true);

					$template_path = Util::normalizePath($template->path . '/html/' . $module);

					// Add the layout options from the template path.
					if (is_dir($template_path) && ($files = App::get('filesystem')->files($template_path, '^[^_]*\.php$')))
					{
						foreach ($files as $i => $file)
						{
							// Remove layout that already exist in component ones
							if (in_array($file, $module_layouts))
							{
								unset($files[$i]);
							}
						}

						if (count($files))
						{
							// Create the group for the template
							$groups[$template->element] = array();
							$groups[$template->element]['id'] = $this->id . '_' . $template->element;
							$groups[$template->element]['text'] = $lang->txt('JOPTION_FROM_TEMPLATE', $template->name);
							$groups[$template->element]['items'] = array();

							foreach ($files as $file)
							{
								// Add an option to the template group
								$value = App::get('filesystem')->name(ltrim($file, DIRECTORY_SEPARATOR));
								$text = $lang->hasKey($key = strtoupper('TPL_' . $template->element . '_' . $module . '_LAYOUT_' . $value))
									? $lang->txt($key)
									: $value;
								$groups[$template->element]['items'][] = Dropdown::option($template->element . ':' . $value, $text);
							}
						}
					}
				}
			}
			// Compute attributes for the grouped list
			$attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';

			// Prepare HTML code
			$html = array();

			// Compute the current selected values
			$selected = array($this->value);

			// Add a grouped list
			$html[] = Dropdown::groupedlist(
				$groups,
				$this->name,
				array(
					'id'          => $this->id,
					'group.id'    => 'id',
					'list.attr'   => $attr,
					'list.select' => $selected
				)
			);

			return implode($html);
		}

		return '';
	}
1118872
function get_data() {
        $mform =& $this->_form;

        if (!$this->is_cancelled() and $this->is_submitted() and $this->is_validated()) {
            $data = $mform->exportValues();
            unset($data['sesskey']); // we do not need to return sesskey
            unset($data['_qf__'.$this->_formname]);   // we do not need the submission marker too
            if (empty($data)) {
                return NULL;
            } else {
                return (object)$data;
            }
        } else {
            return NULL;
        }
    }
48443
protected function loadSubmittedValues(): void
  {
    switch ($this->attributes['method'])
    {
      case 'post':
        $values = &$_POST;
        break;

      case 'get':
        $values = &$_GET;
        break;

      default:
        throw new FallenException('method', $this->attributes['method']);
    }

    // For all field sets load all submitted values.
    $this->fieldSets->loadSubmittedValuesBase($values, $this->values, $this->changedControls);
  }
1097359
private function setFormData()
    {
        $postData = $this->getPostData();
        $currentSetting = $this->getSettings();
        $listSettings = [];

        if ($currentSetting === 'list') {
            $listSettings = $this->getListSettings();
        }

        if ($currentSetting && !isset($postData[self::SOURCE_RADIO_NAME])) {
            $this->sourceElement->setValue($currentSetting);
        }

        if (!empty($listSettings) && !isset($postData[self::SOURCE_LIST_NAME])) {
            $this->sourceDomainsElement->setValue(implode("\n", $listSettings));
        }

        if (isset($postData[self::SOURCE_RADIO_NAME]) && array_key_exists($postData[self::SOURCE_RADIO_NAME], $this->getSourceOptions())) {
            $this->sourceElement->setValue($postData[self::SOURCE_RADIO_NAME]);
        }

        if (isset($postData[self::SOURCE_LIST_NAME])) {
            $this->sourceDomainsElement->setValue($postData[self::SOURCE_LIST_NAME]);
        }
    }
1215425
protected function loadMetaData()
    {
        // Retrieve the transient
        $transientKey = sprintf('WPMVC\Models\Post(%d)::loadMetaData', $this->id());
        $metaData = WP::getTransient($transientKey);
        // If it doesn't exist
        if (!$metaData) {
            $keys = WP::getPostCustom($this->id());
            $metaData = array();
            if ($keys && is_array($keys) && count($keys)) {
                foreach ($keys as $key => $value) {
                    // If only 1 value, it's a string
                    if (is_array($value) && count($value) == 1) {
                        $metaData[$key] = $value[0];
                    } else {
                        $metaData[$key] = $value;
                    }
                }
            }
            WP::setTransient($transientKey, $metaData, static::$transientTimeout);
        }
        $this->metaData = $metaData;
    }
293091
public function ajaxSubmit()
    {
        $this->_add($cb = new jsCallback(), ['desired_name' => 'submit', 'postTrigger' => true]);

        $this->add(new View(['element' => 'input']))
            ->setAttr('name', $cb->postTrigger)
            ->setAttr('value', 'submit')
            ->setStyle(['display' => 'none']);

        $cb->set(function () {
            $caught = function ($e, $useWindow) {
                $html = '<div class="header"> '.
                        htmlspecialchars(get_class($e)).
                        ' </div> <div class="content"> '.
                        ($e instanceof \atk4\core\Exception ? $e->getHTML() : nl2br(htmlspecialchars($e->getMessage()))).
                        ' </div>';
                $this->app->terminate(json_encode(['success' => false, 'message' => $html, 'useWindow' => $useWindow]));
            };

            try {
                $this->loadPOST();
                ob_start();
                $response = $this->hook('submit');
                $output = ob_get_clean();

                if ($output) {
                    $message = new Message('Direct Output Detected');
                    $message->init();
                    $message->addClass('error');
                    $message->text->set($output);

                    return $message;
                }

                if (!$response) {
                    if (!$this->model instanceof \atk4\ui\misc\ProxyModel) {
                        $this->model->save();

                        return $this->success('Form data has been saved');
                    }

                    return new jsExpression('console.log([])', ['Form submission is not handled']);
                }
            } catch (\atk4\data\ValidationException $val) {
                $response = [];
                foreach ($val->errors as $field => $error) {
                    $response[] = $this->error($field, $error);
                }

                return $response;
            } catch (\Error $e) {
                return $caught($e, false);
            } catch (\Exception $e) {
                return $caught($e, true);
            }

            return $response;
        });

        //var_dump($cb->getURL());
        $this->js(true)
            ->api(array_merge(['url' => $cb->getJSURL(), 'method' => 'POST', 'serializeForm' => true], $this->apiConfig))
            ->form(array_merge(['inline' => true, 'on' => 'blur'], $this->formConfig));

        $this->on('change', 'input', $this->js()->form('remove prompt', new jsExpression('$(this).attr("name")')));
    }
1153802
def bind(self, form):
        """"""
        field = self.field(default=self.default, **self.field_kwargs)
        form._fields[self.name] = field.bind(form, self.name, prefix=form._prefix)
702492
protected function doPostGetData()
    {
        foreach ($this->dataTransformers as $dataTransformer) {
            if ($dataTransformer instanceof PostGetDataTransformerInterface) {
                $dataTransformer->postGetData($this->config);
            }
        }
    }
465495
protected function getInput()
	{
		// Initialize variables.

		// Get the client id.
		$clientId = $this->element['client_id'];

		if (is_null($clientId) && $this->form instanceof Form)
		{
			$clientId = $this->form->getValue('client_id');
		}
		$clientId = (int) $clientId;

		$client = ClientManager::client($clientId);

		// Get the extension.
		$extn = (string) $this->element['extension'];

		if (empty($extn) && ($this->form instanceof Form))
		{
			$extn = $this->form->getValue('extension');
		}

		$extn = preg_replace('#\W#', '', $extn);

		// Get the template.
		$template = (string) $this->element['template'];
		$template = preg_replace('#\W#', '', $template);

		// Get the style.
		if ($this->form instanceof Form)
		{
			$template_style_id = $this->form->getValue('template_style_id');
		}

		$template_style_id = preg_replace('#\W#', '', $template_style_id);

		// Get the view.
		$view = (string) $this->element['view'];
		$view = preg_replace('#\W#', '', $view);

		// If a template, extension and view are present build the options.
		if ($extn && $view && $client)
		{
			// Load language file
			$lang = App::get('language');
			$lang->load($extn . '.sys', App::get('component')->path($extn) . '/admin', null, false, true);

			// Get the database object and a new query object.
			$db = App::get('db');

			// Build the query.
			$query = $db->getQuery()
				->select('e.element')
				->select('e.name')
				->from('#__extensions', 'e')
				->whereEquals('e.client_id', (int) $clientId)
				->whereEquals('e.type', 'template')
				->whereEquals('e.enabled', '1');

			if ($template)
			{
				$query->whereEquals('e.element', $template);
			}

			if ($template_style_id)
			{
				$query
					->join('#__template_styles as s', 's.template', 'e.element', 'left')
					->whereEquals('s.id', (int) $template_style_id);
			}

			// Set the query and load the templates.
			$db->setQuery($query->toString());
			$templates = $db->loadObjectList('element');

			// Check for a database error.
			if ($db->getErrorNum())
			{
				throw new Exception(500, $db->getErrorMsg());
			}

			$paths = array(PATH_APP, PATH_CORE);

			$filesystem = App::get('filesystem');

			foreach ($paths as $path)
			{
				if (is_dir($path . '/components/' . $extn))
				{
					break;
				}
			}

			// Build the search paths for component layouts.
			$component_path = Util::normalizePath($path . '/components/' . $extn . '/views/' . $view . '/tmpl');

			// Prepare array of component layouts
			$component_layouts = array();

			// Prepare the grouped list
			$groups = array();

			// Add a Use Global option if useglobal="true" in XML file
			if ($this->element['useglobal'] == 'true')
			{
				$groups[$lang->txt('JOPTION_FROM_STANDARD')]['items'][] = Dropdown::option('', $lang->txt('JGLOBAL_USE_GLOBAL'));
			}

			// Add the layout options from the component path.
			if (is_dir($component_path) && ($component_layouts = $filesystem->files($component_path, '^[^_]*\.xml$', false, true)))
			{
				// Create the group for the component
				$groups['_'] = array();
				$groups['_']['id'] = $this->id . '__';
				$groups['_']['text'] = $lang->txt('JOPTION_FROM_COMPONENT');
				$groups['_']['items'] = array();

				foreach ($component_layouts as $i => $file)
				{
					// Attempt to load the XML file.
					if (!$xml = simplexml_load_file($file))
					{
						unset($component_layouts[$i]);

						continue;
					}

					// Get the help data from the XML file if present.
					if (!$menu = $xml->xpath('layout[1]'))
					{
						unset($component_layouts[$i]);

						continue;
					}

					$menu = $menu[0];

					// Add an option to the component group
					$value = $filesystem->name($file);
					$component_layouts[$i] = $value;
					$text = isset($menu['option']) ? $lang->txt($menu['option']) : (isset($menu['title']) ? $lang->txt($menu['title']) : $value);
					$groups['_']['items'][] = Dropdown::option('_:' . $value, $text);
				}
			}

			// Loop on all templates
			if ($templates)
			{
				foreach ($templates as $template)
				{
					$template->path = '';

					foreach ($paths as $p)
					{
						if (is_dir($p . '/templates/' . $template->element))
						{
							$template->path = $p . '/templates/' . $template->element;
							break;
						}
					}

					if (!$template->path)
					{
						continue;
					}

					// Load language file
					$lang->load('tpl_' . $template->element . '.sys', $template->path, null, false, true);

					$template_path = Util::normalizePath($template->path . '/html/' . $extn . '/' . $view);

					// Add the layout options from the template path.
					if (is_dir($template_path) && ($files = $filesystem->files($template_path, '^[^_]*\.php$', false, true)))
					{
						// Files with corresponding XML files are alternate menu items, not alternate layout files
						// so we need to exclude these files from the list.
						$xml_files = $filesystem->files($template_path, '^[^_]*\.xml$', false, true);
						for ($j = 0, $count = count($xml_files); $j < $count; $j++)
						{
							$xml_files[$j] = $filesystem->name($xml_files[$j]);
						}
						foreach ($files as $i => $file)
						{
							// Remove layout files that exist in the component folder or that have XML files
							if (in_array($filesystem->name($file), $component_layouts) || in_array($filesystem->name($file), $xml_files))
							{
								unset($files[$i]);
							}
						}
						if (count($files))
						{
							// Create the group for the template
							$groups[$template->name] = array();
							$groups[$template->name]['id'] = $this->id . '_' . $template->element;
							$groups[$template->name]['text'] = $lang->txt('JOPTION_FROM_TEMPLATE', $template->name);
							$groups[$template->name]['items'] = array();

							foreach ($files as $file)
							{
								// Add an option to the template group
								$value = $filesystem->name($file);
								$text = $lang->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value))
									? $lang->txt($key)
									: $value;
								$groups[$template->name]['items'][] = Dropdown::option($template->element . ':' . $value, $text);
							}
						}
					}
				}
			}

			// Compute attributes for the grouped list
			$attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';

			// Prepare HTML code
			$html = array();

			// Compute the current selected values
			$selected = array($this->value);

			// Add a grouped list
			$html[] = Dropdown::groupedlist(
				$groups,
				$this->name,
				array(
					'id' => $this->id,
					'group.id' => 'id',
					'list.attr' => $attr,
					'list.select' => $selected
				)
			);

			return implode($html);
		}

		return '';
	}
692634
protected function loadFormData()
    {
        parent::loadFormData();
        $this->loadMailer();

        if (isset($this->formData['gctt'])) {
            $multi = false;
            if (count($this->formData['gctt']) > 1) {
                $multi = true;
                $allLanguages = $this->util->getLocalized()->getLanguages();
            }

            $preview = $this->getPreview($this->formData['gctt']);

            $this->formData['preview_html'] = $preview['html'];
            $this->formData['preview_text'] = $preview['text'];
        }
        if (!isset($this->formData['to'])) {
            $organization = $this->mailer->getOrganization();
            $this->formData['to'] = $this->formData['from'] = $this->currentUser->getEmailAddress();
            if ($organization->getEmail()) {
                $this->formData['from'] = $organization->getEmail();
            } elseif ($this->project->getSiteEmail ()) {
                $this->formData['from'] = $this->project->getSiteEmail();
            }
        }

        $this->formData['available_fields'] = $this->mailElements->displayMailFields($this->mailer->getMailFields());
    }
941509
def post(self, request, *args, **kwargs):
        
        self.init_attachment_cache()

        # Stores a boolean indicating if we are considering a preview
        self.preview = 'preview' in self.request.POST

        # Initializes the forms
        post_form_class = self.get_post_form_class()
        post_form = self.get_post_form(post_form_class)
        attachment_formset_class = self.get_attachment_formset_class()
        attachment_formset = self.get_attachment_formset(attachment_formset_class)

        self.attachment_preview = (
            self.preview if attachment_formset and attachment_formset.is_valid() else None
        )

        post_form_valid = post_form.is_valid()
        if (
            (post_form_valid and attachment_formset is None) or
            (post_form_valid and attachment_formset.is_valid())
        ):
            return self.form_valid(post_form, attachment_formset)
        else:
            return self.form_invalid(post_form, attachment_formset)
179411
public function load( $data, $formName = null ) {

		if( isset( $formName ) && isset( $data[ $formName ] ) ) {

			$this->data	= $data[ $formName ];
		}

		return parent::load( $data, $formName );
	}
1193176
final private function __setDataFromPost()
    {
        // Only set data from $post to App class
        if ($this->template !== 'app') {
            return;
        }

        // Only continue if $post is available
        if (!is_singular()) {
            return;
        }

        // Set $this->post to allow users to use $this->post->post_title and others
        $this->post = get_post();

        // Set the post array to be included in $this->data
        $this->data['post'] = $this->post;
    }
879527
public function postLoad()
    {
        // Ensure class content are known
        $data = (array) $this->_data;
        foreach ($data as $dataEntry) {
            $type = key($dataEntry);

            $dataEntry = array_pop($dataEntry);
            if (true === is_array($dataEntry)) {
                $type = key($dataEntry);
            }

            if ($type !== 'scalar' && $type !== 'array') {
                self::getFullClassname($type);
            }
        }

        parent::postLoad();
    }