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

@param stdClass $form preferences form class
@param array $preferences preferences array
765775
function process_form($form, &$preferences){
        global $CFG;

        if (isset($form->email_email)) {
            $preferences['message_processor_email_email'] = clean_param($form->email_email, PARAM_EMAIL);
        }
        if (isset($form->preference_mailcharset)) {
            $preferences['mailcharset'] = $form->preference_mailcharset;
            if (!array_key_exists($preferences['mailcharset'], get_list_of_charsets())) {
                $preferences['mailcharset'] = '0';
            }
        }
        if (isset($form->mailformat) && isset($form->userid)) {
            require_once($CFG->dirroot.'/user/lib.php');

            $user = core_user::get_user($form->userid, '*', MUST_EXIST);
            $user->mailformat = clean_param($form->mailformat, PARAM_INT);
            user_update_user($user, false, false);
        }
    }
620471
public function editFormSucceeded(Form $form, ArrayHash $values): void
	{
		if ($this->content) {
			$content = $this->content;
		} else {
			$content = new Content;
			$this->orm->content->attach($content);
		}

		try {
			if ($this->editConst) {
				$content->locale = $values->locale;
				$content->setConst($values->const);
			}
			$content->name = $values->name;
			$content->title = $values->title;
			$content->keywords = $values->keywords;
			$content->image = $values->image;
			$content->background = $values->background;
			$content->description = $values->description;
			$content->content = $values->content;

			$this->orm->persistAndFlush($content);
			$this->restoreBacklink();
		} catch (UniqueConstraintViolationException $ex) {
			$form->addError('webManager.web.content.constantExists');
		}
	}
155350
function config_form($preferences){
        global $USER, $OUTPUT, $CFG;
        $string = '';

        $choices = array();
        $choices['0'] = get_string('textformat');
        $choices['1'] = get_string('htmlformat');
        $current = $preferences->mailformat;
        $string .= $OUTPUT->container(html_writer::label(get_string('emailformat'), 'mailformat'));
        $string .= $OUTPUT->container(html_writer::select($choices, 'mailformat', $current, false, array('id' => 'mailformat')));
        $string .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'userid', 'value' => $USER->id));

        if (!empty($CFG->allowusermailcharset)) {
            $choices = array();
            $charsets = get_list_of_charsets();
            if (!empty($CFG->sitemailcharset)) {
                $choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
            } else {
                $choices['0'] = get_string('site').' (UTF-8)';
            }
            $choices = array_merge($choices, $charsets);
            $current = $preferences->mailcharset;
            $string .= $OUTPUT->container(html_writer::label(get_string('emailcharset'), 'mailcharset'));
            $string .= $OUTPUT->container(
                html_writer::select($choices, 'preference_mailcharset', $current, false, array('id' => 'mailcharset'))
            );
        }

        if (!empty($CFG->messagingallowemailoverride)) {
            $inputattributes = array('size' => '30', 'name' => 'email_email', 'value' => $preferences->email_email,
                    'id' => 'email_email');
            $string .= html_writer::label(get_string('email', 'message_email'), 'email_email');
            $string .= $OUTPUT->container(html_writer::empty_tag('input', $inputattributes));

            if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) {
                $string .= $OUTPUT->container(get_string('ifemailleftempty', 'message_email', $preferences->userdefaultemail));
            }

            if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) {
                $string .= $OUTPUT->container(get_string('invalidemail'), 'error');
            }

            $string .= '<br/>';
        }

        return $string;
    }
508499
protected function process_save_extension(& $mform) {
        global $DB, $CFG;

        // Include extension form.
        require_once($CFG->dirroot . '/mod/assign/extensionform.php');
        require_sesskey();

        $users = optional_param('userid', 0, PARAM_INT);
        if (!$users) {
            $users = required_param('selectedusers', PARAM_SEQUENCE);
        }
        $userlist = explode(',', $users);

        $keys = array('duedate', 'cutoffdate', 'allowsubmissionsfromdate');
        $maxoverride = array('allowsubmissionsfromdate' => 0, 'duedate' => 0, 'cutoffdate' => 0);
        foreach ($userlist as $userid) {
            // To validate extension date with users overrides.
            $override = $this->override_exists($userid);
            foreach ($keys as $key) {
                if ($override->{$key}) {
                    if ($maxoverride[$key] < $override->{$key}) {
                        $maxoverride[$key] = $override->{$key};
                    }
                } else if ($maxoverride[$key] < $this->get_instance()->{$key}) {
                    $maxoverride[$key] = $this->get_instance()->{$key};
                }
            }
        }
        foreach ($keys as $key) {
            if ($maxoverride[$key]) {
                $this->get_instance()->{$key} = $maxoverride[$key];
            }
        }

        $formparams = array(
            'instance' => $this->get_instance(),
            'assign' => $this,
            'userlist' => $userlist
        );

        $mform = new mod_assign_extension_form(null, $formparams);

        if ($mform->is_cancelled()) {
            return true;
        }

        if ($formdata = $mform->get_data()) {
            if (!empty($formdata->selectedusers)) {
                $users = explode(',', $formdata->selectedusers);
                $result = true;
                foreach ($users as $userid) {
                    $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
                    $result = $this->save_user_extension($user->id, $formdata->extensionduedate) && $result;
                }
                return $result;
            }
            if (!empty($formdata->userid)) {
                $user = $DB->get_record('user', array('id' => $formdata->userid), '*', MUST_EXIST);
                return $this->save_user_extension($user->id, $formdata->extensionduedate);
            }
        }

        return false;
    }
1123221
public function save(array $form, FormStateInterface $form_state) {
    $entity = $this->entity;
    $query = \Drupal::entityQuery('sport')->condition('name', '%'.$entity->get('name')->value.'%', 'LIKE');
    $id = $query->execute();

    if (count($id) == 0) {
      $status = $entity->save();
      if ($status) {
        drupal_set_message($this->t('Saved the %label Sport.', array(
          '%label' => $entity->label(),
        )));
      } else {
        drupal_set_message($this->t('The %label Sport was not saved.', array(
          '%label' => $entity->label(),
        )));
      }
    } else {
      drupal_set_message($this->t('The %label Sport was not saved as it already exist.', array(
        '%label' => $entity->label(),
      )));
      $entity = entity_load('sport', array_pop($id));
    }

    $form_state->setRedirect('entity.sport.edit_form', ['sport' => $entity->id()]);
  }
519972
public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data, $params) {
        global $USER, $CFG, $SESSION;
        $settings = $this->get_instance();

        $rownum = isset($params['rownum']) ? $params['rownum'] : 0;
        $last = isset($params['last']) ? $params['last'] : true;
        $useridlistid = isset($params['useridlistid']) ? $params['useridlistid'] : 0;
        $userid = isset($params['userid']) ? $params['userid'] : 0;
        $attemptnumber = isset($params['attemptnumber']) ? $params['attemptnumber'] : 0;
        $gradingpanel = !empty($params['gradingpanel']);
        $bothids = ($userid && $useridlistid);

        if (!$userid || $bothids) {
            $useridlist = $this->get_grading_userid_list(true, $useridlistid);
        } else {
            $useridlist = array($userid);
            $rownum = 0;
            $useridlistid = '';
        }

        $userid = $useridlist[$rownum];
        // We need to create a grade record matching this attempt number
        // or the feedback plugin will have no way to know what is the correct attempt.
        $grade = $this->get_user_grade($userid, true, $attemptnumber);

        $submission = null;
        if ($this->get_instance()->teamsubmission) {
            $submission = $this->get_group_submission($userid, 0, false, $attemptnumber);
        } else {
            $submission = $this->get_user_submission($userid, false, $attemptnumber);
        }

        // Add advanced grading.
        $gradingdisabled = $this->grading_disabled($userid);
        $gradinginstance = $this->get_grading_instance($userid, $grade, $gradingdisabled);

        $mform->addElement('header', 'gradeheader', get_string('grade'));
        if ($gradinginstance) {
            $gradingelement = $mform->addElement('grading',
                                                 'advancedgrading',
                                                 get_string('grade').':',
                                                 array('gradinginstance' => $gradinginstance));
            if ($gradingdisabled) {
                $gradingelement->freeze();
            } else {
                $mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
                $mform->setType('advancedgradinginstanceid', PARAM_INT);
            }
        } else {
            // Use simple direct grading.
            if ($this->get_instance()->grade > 0) {
                $name = get_string('gradeoutof', 'assign', $this->get_instance()->grade);
                if (!$gradingdisabled) {
                    $gradingelement = $mform->addElement('text', 'grade', $name);
                    $mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
                    $mform->setType('grade', PARAM_RAW);
                } else {
                    $strgradelocked = get_string('gradelocked', 'assign');
                    $mform->addElement('static', 'gradedisabled', $name, $strgradelocked);
                    $mform->addHelpButton('gradedisabled', 'gradeoutofhelp', 'assign');
                }
            } else {
                $grademenu = array(-1 => get_string("nograde")) + make_grades_menu($this->get_instance()->grade);
                if (count($grademenu) > 1) {
                    $gradingelement = $mform->addElement('select', 'grade', get_string('grade') . ':', $grademenu);

                    // The grade is already formatted with format_float so it needs to be converted back to an integer.
                    if (!empty($data->grade)) {
                        $data->grade = (int)unformat_float($data->grade);
                    }
                    $mform->setType('grade', PARAM_INT);
                    if ($gradingdisabled) {
                        $gradingelement->freeze();
                    }
                }
            }
        }

        $gradinginfo = grade_get_grades($this->get_course()->id,
                                        'mod',
                                        'assign',
                                        $this->get_instance()->id,
                                        $userid);
        if (!empty($CFG->enableoutcomes)) {
            foreach ($gradinginfo->outcomes as $index => $outcome) {
                $options = make_grades_menu(-$outcome->scaleid);
                $options[0] = get_string('nooutcome', 'grades');
                if ($outcome->grades[$userid]->locked) {
                    $mform->addElement('static',
                                       'outcome_' . $index . '[' . $userid . ']',
                                       $outcome->name . ':',
                                       $options[$outcome->grades[$userid]->grade]);
                } else {
                    $attributes = array('id' => 'menuoutcome_' . $index );
                    $mform->addElement('select',
                                       'outcome_' . $index . '[' . $userid . ']',
                                       $outcome->name.':',
                                       $options,
                                       $attributes);
                    $mform->setType('outcome_' . $index . '[' . $userid . ']', PARAM_INT);
                    $mform->setDefault('outcome_' . $index . '[' . $userid . ']',
                                       $outcome->grades[$userid]->grade);
                }
            }
        }

        $capabilitylist = array('gradereport/grader:view', 'moodle/grade:viewall');
        if (has_all_capabilities($capabilitylist, $this->get_course_context())) {
            $urlparams = array('id'=>$this->get_course()->id);
            $url = new moodle_url('/grade/report/grader/index.php', $urlparams);
            $usergrade = '-';
            if (isset($gradinginfo->items[0]->grades[$userid]->str_grade)) {
                $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
            }
            $gradestring = $this->get_renderer()->action_link($url, $usergrade);
        } else {
            $usergrade = '-';
            if (isset($gradinginfo->items[0]->grades[$userid]) &&
                    !$gradinginfo->items[0]->grades[$userid]->hidden) {
                $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
            }
            $gradestring = $usergrade;
        }

        if ($this->get_instance()->markingworkflow) {
            $states = $this->get_marking_workflow_states_for_current_user();
            $options = array('' => get_string('markingworkflowstatenotmarked', 'assign')) + $states;
            $mform->addElement('select', 'workflowstate', get_string('markingworkflowstate', 'assign'), $options);
            $mform->addHelpButton('workflowstate', 'markingworkflowstate', 'assign');
        }

        if ($this->get_instance()->markingworkflow &&
            $this->get_instance()->markingallocation &&
            has_capability('mod/assign:manageallocations', $this->context)) {

            list($sort, $params) = users_order_by_sql('u');
            // Only enrolled users could be assigned as potential markers.
            $markers = get_enrolled_users($this->context, 'mod/assign:grade', 0, 'u.*', $sort);
            $markerlist = array('' =>  get_string('choosemarker', 'assign'));
            $viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
            foreach ($markers as $marker) {
                $markerlist[$marker->id] = fullname($marker, $viewfullnames);
            }
            $mform->addElement('select', 'allocatedmarker', get_string('allocatedmarker', 'assign'), $markerlist);
            $mform->addHelpButton('allocatedmarker', 'allocatedmarker', 'assign');
            $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW);
            $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW);
            $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE);
            $mform->disabledIf('allocatedmarker', 'workflowstate', 'eq', ASSIGN_MARKING_WORKFLOW_STATE_RELEASED);
        }
        $gradestring = '<span class="currentgrade">' . $gradestring . '</span>';
        $mform->addElement('static', 'currentgrade', get_string('currentgrade', 'assign'), $gradestring);

        if (count($useridlist) > 1) {
            $strparams = array('current'=>$rownum+1, 'total'=>count($useridlist));
            $name = get_string('outof', 'assign', $strparams);
            $mform->addElement('static', 'gradingstudent', get_string('gradingstudent', 'assign'), $name);
        }

        // Let feedback plugins add elements to the grading form.
        $this->add_plugin_grade_elements($grade, $mform, $data, $userid);

        // Hidden params.
        $mform->addElement('hidden', 'id', $this->get_course_module()->id);
        $mform->setType('id', PARAM_INT);
        $mform->addElement('hidden', 'rownum', $rownum);
        $mform->setType('rownum', PARAM_INT);
        $mform->setConstant('rownum', $rownum);
        $mform->addElement('hidden', 'useridlistid', $useridlistid);
        $mform->setType('useridlistid', PARAM_ALPHANUM);
        $mform->addElement('hidden', 'attemptnumber', $attemptnumber);
        $mform->setType('attemptnumber', PARAM_INT);
        $mform->addElement('hidden', 'ajax', optional_param('ajax', 0, PARAM_INT));
        $mform->setType('ajax', PARAM_INT);
        $mform->addElement('hidden', 'userid', optional_param('userid', 0, PARAM_INT));
        $mform->setType('userid', PARAM_INT);

        if ($this->get_instance()->teamsubmission) {
            $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'assign'));
            $mform->addElement('selectyesno', 'applytoall', get_string('applytoteam', 'assign'));
            $mform->setDefault('applytoall', 1);
        }

        // Do not show if we are editing a previous attempt.
        if (($attemptnumber == -1 ||
            ($attemptnumber + 1) == count($this->get_all_submissions($userid))) &&
            $this->get_instance()->attemptreopenmethod != ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) {
            $mform->addElement('header', 'attemptsettings', get_string('attemptsettings', 'assign'));
            $attemptreopenmethod = get_string('attemptreopenmethod_' . $this->get_instance()->attemptreopenmethod, 'assign');
            $mform->addElement('static', 'attemptreopenmethod', get_string('attemptreopenmethod', 'assign'), $attemptreopenmethod);

            $attemptnumber = 0;
            if ($submission) {
                $attemptnumber = $submission->attemptnumber;
            }
            $maxattempts = $this->get_instance()->maxattempts;
            if ($maxattempts == ASSIGN_UNLIMITED_ATTEMPTS) {
                $maxattempts = get_string('unlimitedattempts', 'assign');
            }
            $mform->addelement('static', 'maxattemptslabel', get_string('maxattempts', 'assign'), $maxattempts);
            $mform->addelement('static', 'attemptnumberlabel', get_string('attemptnumber', 'assign'), $attemptnumber + 1);

            $ismanual = $this->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL;
            $issubmission = !empty($submission);
            $isunlimited = $this->get_instance()->maxattempts == ASSIGN_UNLIMITED_ATTEMPTS;
            $islessthanmaxattempts = $issubmission && ($submission->attemptnumber < ($this->get_instance()->maxattempts-1));

            if ($ismanual && (!$issubmission || $isunlimited || $islessthanmaxattempts)) {
                $mform->addElement('selectyesno', 'addattempt', get_string('addattempt', 'assign'));
                $mform->setDefault('addattempt', 0);
            }
        }
        if (!$gradingpanel) {
            $mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
        } else {
            $mform->addElement('hidden', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
            $mform->setType('sendstudentnotifications', PARAM_BOOL);
        }
        // Get assignment visibility information for student.
        $modinfo = get_fast_modinfo($settings->course, $userid);
        $cm = $modinfo->get_cm($this->get_course_module()->id);

        // Don't allow notification to be sent if the student can't access the assignment,
        // or until in "Released" state if using marking workflow.
        if (!$cm->uservisible) {
            $mform->setDefault('sendstudentnotifications', 0);
            $mform->freeze('sendstudentnotifications');
        } else if ($this->get_instance()->markingworkflow) {
            $mform->setDefault('sendstudentnotifications', 0);
            if (!$gradingpanel) {
                $mform->disabledIf('sendstudentnotifications', 'workflowstate', 'neq', ASSIGN_MARKING_WORKFLOW_STATE_RELEASED);
            }
        } else {
            $mform->setDefault('sendstudentnotifications', $this->get_instance()->sendstudentnotifications);
        }

        $mform->addElement('hidden', 'action', 'submitgrade');
        $mform->setType('action', PARAM_ALPHA);

        if (!$gradingpanel) {

            $buttonarray = array();
            $name = get_string('savechanges', 'assign');
            $buttonarray[] = $mform->createElement('submit', 'savegrade', $name);
            if (!$last) {
                $name = get_string('savenext', 'assign');
                $buttonarray[] = $mform->createElement('submit', 'saveandshownext', $name);
            }
            $buttonarray[] = $mform->createElement('cancel', 'cancelbutton', get_string('cancel'));
            $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
            $mform->closeHeaderBefore('buttonar');
            $buttonarray = array();

            if ($rownum > 0) {
                $name = get_string('previous', 'assign');
                $buttonarray[] = $mform->createElement('submit', 'nosaveandprevious', $name);
            }

            if (!$last) {
                $name = get_string('nosavebutnext', 'assign');
                $buttonarray[] = $mform->createElement('submit', 'nosaveandnext', $name);
            }
            if (!empty($buttonarray)) {
                $mform->addGroup($buttonarray, 'navar', '', array(' '), false);
            }
        }
        // The grading form does not work well with shortforms.
        $mform->setDisableShortforms();
    }
1066097
public function updateSearchForm(Form $form)
    {
        if ($this->isVersioned()) {
            
            // Obtain Field List:
            
            $fields = $form->Fields();
            
            // Create Filter Field:
            
            $filter = DropdownField::create(
                'q[FilterClass]',
                $this->owner->getStatusFieldTitle(),
                $this->getFilterClassOptions(),
                $this->getFilterClass()
            )->setForm($form);
            
            // Add Filter Field to Form:
            
            if ($this->owner->StatusFieldBefore) {
                $fields->insertBefore(sprintf('q[%s]', $this->owner->StatusFieldBefore), $filter);
            } elseif ($this->owner->StatusFieldAfter) {
                $fields->insertAfter(sprintf('q[%s]', $this->owner->StatusFieldAfter), $filter);
            } else {
                $fields->push($filter);
            }
            
        }
    }
561639
public function updateEditForm($form) {
        $classNameField = $form->Fields()->dataFieldByName('ClassName');
        if ($classNameField) {
            $className = $classNameField->Value();
            if ($className === 'Site') 
            {
            	$form->Fields()->removeByName(array(SilverStripeNavigator::class));
                $form->removeExtraClass('cms-previewable');
            }
        }
    }
87671
public function submitForm(array &$form, FormStateInterface $form_state)
    {
        $group   = &$form_state->getTemporaryValue('group');
        $values  = &$form_state->getValues();

        /** @var $group Group */
        $group->setTitle($values['title']);
        $group->setIsGhost($values['is_ghost']);

        foreach (['allowed_themes'] as $name) {
            $list = $form_state->getValue($name, []);
            $list = array_values(array_filter($list));
            if ($list) {
                $group->setAttribute($name, $list);
            } else {
                $group->deleteAttribute($name);
            }
        }

        $isNew = !$group->getId();

        $this->groupManager->save($group, ['title', 'is_ghost', 'attributes']);
        if ($isNew) {
            drupal_set_message($this->t("Group %title has been created", ['%title' => $group->getTitle()]));
        } else {
            drupal_set_message($this->t("Group %title has been updated", ['%title' => $group->getTitle()]));
        }

        $form_state->setRedirect('admin/dashboard/group/' . $group->getId());
    }
330273
public function config_form_display(&$mform, $data = null) {
        $mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
        $mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
        $mform->disabledIf('criteria_grade_value', 'criteria_grade');
        $mform->setType('criteria_grade_value', PARAM_RAW); // Uses unformat_float.
        // Grades are stored in Moodle with 5 decimal points, make sure we do not accidentally round them
        // when setting the form value.
        $mform->setDefault('criteria_grade_value', format_float($data, 5));

        if ($this->id) {
            $mform->setDefault('criteria_grade', 1);
            $mform->setDefault('criteria_grade_value', format_float($this->gradepass, 5));
        }
    }
1336626
public function add(array $post, Form $form = null)
    {
        $model  = $this->getModel();
        $form   = ($form instanceof Form) ?
            $form->setData($post) :
            $this->prepareForm($model, $post, true, true);
        $argv   = compact('post', 'form');
        $argv   = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_PRE_ADD, $this, $argv);

        if (!$form->isValid()) {
            return $form;
        }

        $saved  = $this->save($form->getData());
        $argv   = compact('post', 'form', 'saved');
        $argv   = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_POST_ADD, $this, $argv);

        return $saved;
    }
517669
public function save(Form $form)
    {
        $this->em->persist($form);
        $this->em->flush();

        return $form;
    }
924666
public function define_form_specific($form) {
        // Select whether or not this should be checked by default.
        $form->addElement('selectyesno', 'defaultdata', get_string('profiledefaultchecked', 'admin'));
        $form->setDefault('defaultdata', 0); // Defaults to 'no'.
        $form->setType('defaultdata', PARAM_BOOL);
    }
753080
public function success(Form $form) : void
    {
        if ($this->presenter->isAjax())
        {
            $values = $form->getValues();

            if ($values->count() === 0)
            {
                throw new ForbiddenRequestException;
            }

            $status = UserAuthorizator::ALL_STATUS_KEYS[$values->status];
            $role = UserAuthorizator::ALL_ROLE_KEYS[$values->role];

            $this->userManager->getConnection()->beginTransaction();

            try
            {
                $user = $this->userManager->add($values->email, NULL, $status);
                $this->userRoleManager->addRole($user, $role);
                
                $this->userPersonalDataManager->saveName($user, $values->firstName, $values->lastName);
                $this->userPersonalDataManager->savePhone($user, $values->phone);

                $this->userManager->getConnection()->commit();

                $this->presenter->notificationAjax(
                    'Uživatel vytvořen',
                    "Uživatel {$values->email} byl úspěšně vytvořen.",
                    'success',
                    FALSE
                );

                $this->presenter->handleModalToggle('hide', '#wakers_user_add_modal', FALSE);

                $form->reset();
                $this->onSave();

            }
            catch (DatabaseException $exception)
            {
                $this->userManager->getConnection()->rollBack();

                $this->presenter->notificationAjax(
                    'Chyba',
                    $exception->getMessage(),
                    'error'
                );
            }
            catch (\Exception $exception)
            {
                $this->userManager->getConnection()->rollBack();
                throw $exception;
            }
        }
    }
977057
public function updateEditForm($form)
    {
        if ($this->isAssetAdmin() && $this->hasSecureAssets()) {
            
            if (($record = $form->getRecord()) && $record instanceof Folder) {
                
                if ($field = $form->Fields()->dataFieldByName('ViewerGroups')) {
                    
                    // Create Form Object:
                    
                    $dummy = Form::create(
                        $this->owner,
                        'EditForm',
                        FieldList::create(),
                        FieldList::create()
                    );
                    
                    // Populate Form Data:
                    
                    $dummy->loadDataFrom($record);
                    
                    // Define Form Action (allows ViewerGroups field to work in asset EditForm):
                    
                    $dummy->setFormAction(
                        sprintf(
                            '%s/field/File/item/%d/ItemEditForm',
                            $form->FormAction(),
                            $record->ID
                        )
                    );
                    
                    // Update Field Object:
                    
                    $field->setForm($dummy);
                    
                }
                
            }
            
        }
    }
990732
public function save(Post $form)
    {
        $this->em->persist($form);
        $this->em->flush();

        return $form;
    }
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();
            }
        }
    }