Parses the submitted form data and saves it into preferences array.

@param stdClass $form preferences form class
@param array $preferences preferences array
552744
function process_form($form, &$preferences){
        if (isset($form->jabber_jabberid) && !empty($form->jabber_jabberid)) {
            $preferences['message_processor_jabber_jabberid'] = $form->jabber_jabberid;
        }
    }
826329
public function registerAdministratorFormSucceeded(Form $form, ArrayHash $values): void
	{
		$password = $values->password;

		$role = $this->orm->aclRoles->getByName(AclRolesMapper::SUPERADMIN);

		$user = new User;
		$user->firstName = $values->firstName;
		$user->surname = $values->surname;
		$user->email = $values->email;
		$user->username = $values->username;
		$user->setPassword($password);
		$user->roles->add($role);

		$this->orm->persistAndFlush($user);

		$this->user->setExpiration('+ ' . $this->loginExpiration, true);
		$this->user->login($values->username, $password);

		$this->flashNotifier->success('cms.user.dataSaved');

		$this->redirect(":{$this->module}:Homepage:");
	}
1038401
public function save($data, $form)
    {
        $request = $this->getRequest();
        $className = $this->config()->get('tree_class');

        // Existing or new record?
        $id = $data['ID'];
        if (is_numeric($id) && $id > 0) {
            $record = DataObject::get_by_id($className, $id);
            if ($record && !$record->canEdit()) {
                return Security::permissionFailure($this);
            }
            if (!$record || !$record->ID) {
                $this->httpError(404, "Bad record ID #" . (int)$id);
            }
        } else {
            if (!singleton($this->config()->get('tree_class'))->canCreate()) {
                return Security::permissionFailure($this);
            }
            $record = $this->getNewItem($id, false);
        }

        // save form data into record
        $form->saveInto($record, true);
        $record->write();
        $this->extend('onAfterSave', $record);
        $this->setCurrentPageID($record->ID);

        $message = _t(__CLASS__ . '.SAVEDUP', 'Saved.');
        if ($this->getSchemaRequested()) {
            $schemaId = Controller::join_links($this->Link('schema/DetailEditForm'), $id);
            // Ensure that newly created records have all their data loaded back into the form.
            $form->loadDataFrom($record);
            $form->setMessage($message, 'good');
            $response = $this->getSchemaResponse($schemaId, $form);
        } else {
            $response = $this->getResponseNegotiator()->respond($request);
        }

        $response->addHeader('X-Status', rawurlencode($message));
        return $response;
    }
932849
public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->configFactory()
      ->getEditable('openy_upgrade_tool.settings')
      ->set('force_mode', $form_state->getValue('force_mode'))
      ->save();
  }
321984
public function settingsFormSucceeded(Form $form, ArrayHash $values): void
	{
		$this->configurator->logo = $values->logo;
		$this->configurator->title = $values->title;
		$this->configurator->keywords = $values->keywords;
		$this->configurator->description = $values->description;
		$this->flashNotifier->success('webManager.web.settings.saved');

		if ($this->isAjax()) {
			$this->redrawControl('settings');
		} else {
			$this->redirect('default');
		}
	}
49089
private static function _parse_form_attributes($attributes, $default)
    {
        if (is_array($attributes)) {
            foreach ($default as $key => $val) {
                if (isset($attributes[$key])) {
                    $default[$key] = $attributes[$key];
                    unset($attributes[$key]);
                }
            }

            if (count($attributes) > 0) {
                $default = array_merge($default, $attributes);
            }
        }

        $att = '';

        foreach ($default as $key => $val) {
            if ($key == 'value') {
                $val = self::form_prep($val, $default['name']);
            }

            $att .= $key . '="' . $val . '" ';
        }

        return $att;
    }
930465
public static function config_set_edit_form_data(moodleform $editform, array $config) {
        $data = array();
        if (!empty($config['path'])) {
            $data['path'] = $config['path'];
        }
        if (isset($config['autocreate'])) {
            $data['autocreate'] = (bool)$config['autocreate'];
        }
        if (isset($config['singledirectory'])) {
            $data['singledirectory'] = (bool)$config['singledirectory'];
        }
        if (isset($config['prescan'])) {
            $data['prescan'] = (bool)$config['prescan'];
        }
        $editform->set_data($data);
    }
700152
protected function process_save_grade(&$mform) {
        global $CFG, $SESSION;
        // Include grade form.
        require_once($CFG->dirroot . '/mod/assign/gradeform.php');

        require_sesskey();

        $instance = $this->get_instance();
        $rownum = required_param('rownum', PARAM_INT);
        $attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
        $useridlistid = optional_param('useridlistid', $this->get_useridlist_key_id(), PARAM_ALPHANUM);
        $userid = optional_param('userid', 0, PARAM_INT);
        if (!$userid) {
            if (empty($SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)])) {
                // If the userid list is not stored we must not save, as it is possible that the user in a
                // given row position may not be the same now as when the grading page was generated.
                $url = new moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id));
                throw new moodle_exception('useridlistnotcached', 'mod_assign', $url);
            }
            $useridlist = $SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)];
        } else {
            $useridlist = array($userid);
            $rownum = 0;
        }

        $last = false;
        $userid = $useridlist[$rownum];
        if ($rownum == count($useridlist) - 1) {
            $last = true;
        }

        $data = new stdClass();

        $gradeformparams = array('rownum' => $rownum,
                                 'useridlistid' => $useridlistid,
                                 'last' => $last,
                                 'attemptnumber' => $attemptnumber,
                                 'userid' => $userid);
        $mform = new mod_assign_grade_form(null,
                                           array($this, $data, $gradeformparams),
                                           'post',
                                           '',
                                           array('class'=>'gradeform'));

        if ($formdata = $mform->get_data()) {
            return $this->save_grade($userid, $formdata);
        } else {
            return false;
        }
    }
1281846
public function passwordFormSucceeded(Form $form, ArrayHash $values): void
	{
		if ($values->generatePassword) {
			$password = Random::generate($this->minPasswordLength, $this->passwordChars);
		} else {
			$password = $values->password;
		}

		$this->currentUser->setPassword($password);

		$this->orm->persistAndFlush($this->currentUser);

		if ($this->configurator->sendChangePassword) {
			$this->mailer->sendNewPassword($this->currentUser->email, $this->currentUser->username, $password);
		}

		$this->flashNotifier->success('cms.user.passwordChanged');
		$this->restoreBacklink();
	}
1318803
public function submitForm(array &$form, FormStateInterface $form_state) {
    if ($group_type = $form_state->getValue('group_type')) {
      $url = Url::fromUserInput('/group/add/' . $group_type);

      $form_state->setRedirectUrl($url);
    }
  }
194877
public function save(array $data, Form $form)
    {
        $member = Member::currentUser();

        $groupIds = $this->getSettableGroupIdsFrom($form, $member);
        $member->Groups()->setByIDList($groupIds);

        $form->saveInto($member);

        try {
            $member->write();
        } catch (ValidationException $e) {
            $validationMessages = implode("; ", $e->getResult()->getMessages());
            $form->sessionMessage($validationMessages, 'bad');
            return $this->redirectBack();
        }

        $form->sessionMessage(
            _t('MemberProfiles.PROFILEUPDATED', 'Your profile has been updated.'),
            'good'
        );
        return $this->redirectBack();
    }
917621
public function buildResults(array &$form, FormStateInterface $form_state) {
    $user_input = $form_state->getUserInput();

    $values = $form_state->getValues();
    $query = $this->state;
    $filter_date = NULL;
    if (!isset($values['location']) && is_numeric($query['location'])) {
      $values['location_select'] = $values['location'] = $query['location'];
    }
    if (!isset($values['date']) && !empty($query['filter_date'])) {
      $values['date_select'] = $values['date'] = $query['filter_date'];
    }
    $location = !empty($values['location_select']) ? $values['location_select'] : $values['location'];
    if (isset($values['date'])) {
      $filter_date = !empty($values['date_select']) ? $values['date_select'] : $values['date'];
    }
    if (isset($user_input['date_select']) && $user_input['date_select'] != $filter_date) {
      $filter_date = $user_input['date_select'];
    }
    $class = !empty($values['class_select']) ? $values['class_select'] : 'any';
    if ($class == 'any' && empty($user_input['class_select']) && is_numeric($query['class'])) {
      $class = $query['class'];
    }
    $category = !empty($values['category_select']) ? $values['category_select'] : 'any';
    if ($category == 'any' && empty($user_input['category_select']) && is_numeric($query['category'])) {
      $category = $query['category_select'];
    }

    $filter_length = !empty($query['filter_length']) ? $query['filter_length'] : 'day';
    $groupex_class = !empty($query['groupex_class']) ? $query['groupex_class'] : 'groupex_table_class';
    $triggering_element = $form_state->getTriggeringElement();
    // Reset to day length in any case if date select has been changed.
    if (isset($triggering_element['#name']) && $triggering_element['#name'] == 'date_select') {
      $filter_length = 'day';
    }
    // Reset to day length in any case if date select has been changed.
    if (isset($triggering_element['#name']) && $triggering_element['#name'] == 'location_select' && is_numeric($class)) {
      $filter_length = 'week';
      $groupex_class = 'groupex_table_class_individual';
      $view_mode = 'class';
    }
    if (isset($triggering_element['#name']) && $triggering_element['#name'] == 'class_select' && $triggering_element['#value'] != 'any') {
      $class = $triggering_element['#value'];
      $filter_length = 'week';
      $groupex_class = 'groupex_table_class_individual';
      $view_mode = 'class';
    }
    if (isset($triggering_element['#name']) && $triggering_element['#name'] == 'category_select' && $triggering_element['#value'] != 'any') {
      $category = $triggering_element['#value'];
      $filter_length = 'week';
      $groupex_class = 'groupex_table_class_individual';
      $view_mode = 'class';
    }
    if (isset($triggering_element['#name']) && $triggering_element['#name'] == 'location_select' && $groupex_class = 'groupex_table_instructor_individual') {
      $location = $triggering_element['#value'];
      $class = 'any';
      $filter_length = 'day';
      $groupex_class = 'groupex_table_class';
    }
    $parameters = [
      'location' => $location,
      'class' => $class,
      'category' => $category,
      'filter_length' => $filter_length,
      'filter_date' => $filter_date,
      'groupex_class' => $groupex_class,
    ];
    // Add optional parameters.
    if (!empty($user_input['instructor_select'])) {
      $parameters['instructor'] = $user_input['instructor_select'];
    }
    elseif (!empty($query['instructor'])) {
      $parameters['instructor'] = $query['instructor'];
    }
    if (isset($view_mode)) {
      $parameters['view_mode'] = $view_mode;
    }
    if (isset($triggering_element['#name']) && $triggering_element['#name'] == 'location_select' && $groupex_class = 'groupex_table_instructor_individual') {
      unset($parameters['instructor']);
      unset($parameters['view_mode']);
    }

    // Remove instructor parameter in case of no instructor selected.
    if (isset($parameters['instructor']) && $parameters['instructor'] == 'any') {
      unset($parameters['instructor']);
    }

    $this->scheduleFetcher->__construct($this->groupexHelper, $this->configFactory, $parameters);

    // Get classes schedules.
    $schedule = $this->scheduleFetcher->getSchedule();
    // Are results empty?
    $formatted_results = $this->t('No results. Please try again.');
    if (!$empty_results = $this->scheduleFetcher->isEmpty()) {
      // Format results as table view.
      $formatted_results = openy_group_schedules_schedule_table_layout($schedule);
    }
    return $formatted_results;
  }
702238
private function processPreferences($preferences, $processedPreferences)
    {
        foreach ($preferences as $preference) {
            $formattedPreference = [];
            $formattedPreference['isPreference'] = $preference->isPreference;
            if (! $preference->isPreference) {
                if (! isset($preference->preferences)) {
                    continue;
                }
                $formattedPreference['catLabel'] = $preference->publicName;
                $formattedCatPreferences = [];
                foreach ($preference->preferences as $catPreference) {
                    $formattedCatPreference = [];
                    $formattedCatPreference['label'] = $catPreference->publicName;
                    isset($catPreference->isOptedIn)? $formattedCatPreference['isOptedIn'] = $catPreference->isOptedIn :
                        $formattedCatPreference['isOptedIn'] = false;
                    $formattedCatPreferences[$catPreference->id] = $formattedCatPreference;
                }
                $formattedPreference['catPreferences'] = $formattedCatPreferences;
            } else {
                $formattedPreference['label'] = $preference->publicName;
                isset($catPreference->isOptedIn)? $formattedPreference['isOptedIn'] = $preference->isOptedIn :
                    $formattedPreference['isOptedIn'] = false;
            }
            $processedPreferences[$preference->id] = $formattedPreference;
        }
        return $processedPreferences;
    }
656857
protected function populatePreviousData(Form $form) {
		$prepops = EventAttendee::config()->prepopulated_fields;
		if (!$prepops) {
			return;
		}
		$latestattendee = $this->registration->Attendees()
			->sort("LastEdited", "DESC")->first();
		if($latestattendee){
			$form->loadDataFrom($latestattendee, Form::MERGE_DEFAULT, $prepops);	
		}
	}
743885
protected function process_form_data(array $form) {

        $count = count($form); // number of form field values

        if ($count % 5) {
            // we must get five fields per emoticon object
            return false;
        }

        $emoticons = array();
        for ($i = 0; $i < $count / 5; $i++) {
            $emoticon                   = new stdClass();
            $emoticon->text             = clean_param(trim($form['text'.$i]), PARAM_NOTAGS);
            $emoticon->imagename        = clean_param(trim($form['imagename'.$i]), PARAM_PATH);
            $emoticon->imagecomponent   = clean_param(trim($form['imagecomponent'.$i]), PARAM_COMPONENT);
            $emoticon->altidentifier    = clean_param(trim($form['altidentifier'.$i]), PARAM_STRINGID);
            $emoticon->altcomponent     = clean_param(trim($form['altcomponent'.$i]), PARAM_COMPONENT);

            if (strpos($emoticon->text, ':/') !== false or strpos($emoticon->text, '//') !== false) {
                // prevent from breaking http://url.addresses by accident
                $emoticon->text = '';
            }

            if (strlen($emoticon->text) < 2) {
                // do not allow single character emoticons
                $emoticon->text = '';
            }

            if (preg_match('/^[a-zA-Z]+[a-zA-Z0-9]*$/', $emoticon->text)) {
                // emoticon text must contain some non-alphanumeric character to prevent
                // breaking HTML tags
                $emoticon->text = '';
            }

            if ($emoticon->text !== '' and $emoticon->imagename !== '' and $emoticon->imagecomponent !== '') {
                $emoticons[] = $emoticon;
            }
        }
        return $emoticons;
    }
554710
public function addForm(QuickForm2 $form)
    {

        // assign array with form data
        $this->assign('form_data', $form->getFormData());
        $this->assign('element_list', $form->getElementList());
    }
245835
public function success(Form $form) : void
    {
        if ($this->presenter->isAjax())
        {
            $values = $form->getValues();

            try
            {
                $urlBefore = $this->activePage->getPageUrl()->getUrl();
                $urlAfter = $this->pageUrlManager->saveUrl($this->activeLang, $this->activePage, $values->url);

                if ($urlBefore !== $urlAfter->getUrl())
                {
                    $this->presenter->notification(
                        'URL stránky',
                        'URL stránky byla úspěšně uložena.',
                        'success'
                    );

                    $this->presenter->redirect(':App:Run:setUrl', ['url' => $urlAfter->getUrl()]);
                }
                else
                {
                    $this->presenter->notificationAjax(
                        'URL stránky',
                        'URL stránky byla úspěšně uložena.',
                        'success'
                    );
                }
            }
            catch (DatabaseException $exception)
            {
                $form->setValues([
                    'url' => $this->activePage->getPageUrl()->getUrl()
                ]);

                $this->presenter->notificationAjax(
                    'Chyba',
                    $exception->getMessage(),
                    'error',
                    FALSE
                );

                $this->onSaveFail();
            }
        }
    }