Set what to do when the form is 'finished'.

@return \MUtil_Snippets_ModelFormSnippetAbstract (continuation pattern)
545396
protected function setAfterSaveRoute()
    {
        parent::setAfterSaveRoute();

        if ($this->afterSaveRouteUrl) {
            $this->afterSaveRouteUrl[\MUtil_Model::REQUEST_ID] = $this->formData['gtf_id_track'];
            $this->afterSaveRouteUrl[\Gems_Model::FIELD_ID]    = $this->formData['gtf_id_field'];
            $this->afterSaveRouteUrl['sub']                    = $this->formData['sub'];
        }

        return $this;
    }
378756
public function setForm($form)
    {
        // Associate Form Instance (via parent):
        
        parent::setForm($form);
        
        // Associate Rules with Fields:
        
        foreach ($this->rules as $fieldName => $rules) {
            
            if ($field = $this->getDataField($fieldName)) {
                
                foreach ($rules as $rule) {
                    $rule->setField($field);
                }
                
            }
            
        }
        
        // Associate Backend with Self:
        
        $this->backend->setFrontend($this);
        
        // Initialise Backend:
        
        $this->backend->doInit();
        
        // Define Form Classes:
        
        if ($classes = $this->getClassesForForm($form)) {
            
            foreach ($classes as $class) {
                $form->addExtraClass($class);
            }
            
        }
        
        // Define Form Attributes:
        
        if ($attributes = $this->getAttributesForForm($form)) {
            
            foreach ($attributes as $key => $value) {
                $form->setAttribute($key, $value);
            }
            
        }
        
        // Answer Self:
        
        return $this;
    }
480093
public function Form()
    {
        $form = new Form(
            $this,
            'SilverStripe\\Forms\\Form',
            new FieldList($root = new TabSet('Root', new Tab('Main'))),
            new FieldList()
        );

        if ($this->getTopLevelController() instanceof LeftAndMain) {
            $form->setTemplate('LeftAndMain_EditForm');
            $form->addExtraClass('cms-content cms-edit-form cms-tabset center');
            $form->setAttribute('data-pjax-fragment', 'CurrentForm Content');

            $root->setTemplate('CMSTabSet');
            $form->Backlink = $this->getBackLink();
        }

        return $form;
    }
383389
protected function onInputEnd()
    {
        $data = array();
        if (Utility::isAssoc($this->params)) {
            $data = array($this->params);
        } else {
            $data = $this->params;
        }
        foreach ($data as $row) {
            $this->next($row);
        }
    }
57281
public function actionSend()
    {
        $model = new MessageSendForm();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['index']);
        }
        return $this->render('send', ['model' => $model]);
    }
699950
public function definition() {
        $mform = $this->_form;
        $context = $this->_customdata['context'];

        $mform->addElement('hidden', 'userid');
        $mform->setType('userid', PARAM_INT);
        $mform->setConstant('userid', $this->_customdata['userid']);

        $mform->addElement('header', 'generalhdr', get_string('general'));

        // Name.
        $mform->addElement('text', 'name', get_string('planname', 'tool_lp'), 'maxlength="100"');
        $mform->setType('name', PARAM_TEXT);
        $mform->addRule('name', null, 'required', null, 'client');
        $mform->addRule('name', get_string('maximumchars', '', 100), 'maxlength', 100, 'client');
        // Description.
        $mform->addElement('editor', 'description', get_string('plandescription', 'tool_lp'), array('rows' => 4));
        $mform->setType('description', PARAM_CLEANHTML);

        $mform->addElement('date_time_selector', 'duedate', get_string('duedate', 'tool_lp'), array('optional' => true));
        $mform->addHelpButton('duedate', 'duedate', 'tool_lp');

        // Display status selector in form.
        // When the plan was already saved then the status can not be changed via this form.
        $status = planpersistent::get_status_list($this->_customdata['userid']);
        $plan = $this->get_persistent();
        if ($plan->get('id')) {
            // The current status is not selectable (workflow status probably), we just display it.
            $mform->addElement('static', 'staticstatus', get_string('status', 'tool_lp'), $plan->get_statusname());
        } else if (!empty($status) && count($status) > 1) {
            // There is more than one status to select from.
            $mform->addElement('select', 'status', get_string('status', 'tool_lp'), $status);
        } else if (count($status) === 1) {
            // There is only one status to select from.
            $mform->addElement('static', 'staticstatus', get_string('status', 'tool_lp'), current($status));
        } else {
            throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', '');
        }

        // Disable short forms.
        $mform->setDisableShortforms();
        $this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
    }
915469
public function definition() {
        $mform = $this->_form;
        $mform->addElement('hidden', 'returnurl', $this->_customdata['returnurl']);
        $mform->setType('returnurl', PARAM_LOCALURL);
        $mform->addElement('submit', 'all', get_string('purgecaches', 'admin'));
        $mform->addElement('header', 'purgecacheheader', get_string('purgeselectedcaches', 'admin'));
        $checkboxes = [
            $mform->createElement('advcheckbox', 'theme', '', get_string('purgethemecache', 'admin')),
            $mform->createElement('advcheckbox', 'lang', '', get_string('purgelangcache', 'admin')),
            $mform->createElement('advcheckbox', 'js', '', get_string('purgejscache', 'admin')),
            $mform->createElement('advcheckbox', 'filter', '', get_string('purgefiltercache', 'admin')),
            $mform->createElement('advcheckbox', 'muc', '', get_string('purgemuc', 'admin')),
            $mform->createElement('advcheckbox', 'other', '', get_string('purgeothercaches', 'admin'))
        ];
        $mform->addGroup($checkboxes, 'purgeselectedoptions');
        $mform->addElement('submit', 'purgeselectedcaches', get_string('purgeselectedcaches', 'admin'));
    }
1091056
protected function setAfterSaveRoute()
    {
        // Default is just go to the index
        if ($this->routeAction && ($this->request->getActionName() !== $this->routeAction)) {
            $tokenId = $this->_replacementTokenId ? $this->_replacementTokenId : $this->token->getTokenId();
            $this->afterSaveRouteUrl = array(
                $this->request->getActionKey() => $this->routeAction,
                \MUtil_Model::REQUEST_ID       => $tokenId,
                );
        }

        return $this;
    }
1216568
public function definition() {
        $mform = $this->_form;
        $badge = $this->_customdata['badge'];
        $badgesarray = $this->get_badges_option($badge);
        $mform->addElement('header', 'alignment', get_string('relatedbages', 'badges'));
        if (!$badgesarray) {
            $badgesarray = array(get_string('none'));
            $attributes = array('size' => '3', 'disabled' => true, 'style' => 'min-width: 200px');
        } else {
            $attributes = array('size' => '10');
        }
        $mform->addElement('select', 'relatedbadgeids', get_string('relatedbages', 'badges'), $badgesarray, $attributes);
        $mform->getElement('relatedbadgeids')->setMultiple(true);
        $this->add_action_buttons();

        // Freeze all elements if badge is active or locked.
        if ($badge->is_active() || $badge->is_locked()) {
            $mform->hardFreezeAllVisibleExcept(array());
        }
    }
192939
function finishForm(&$form)
    {
        // add a required note, if one is needed
        if (!empty($form->_required) && !$form->_freezeAll) {
            $this->_html .= str_replace('{requiredNote}', $form->getRequiredNote(), $this->_requiredNoteTemplate);
        }
        // add form attributes and content
        $html = str_replace('{attributes}', $form->getAttributes(true), $this->_formTemplate);
        if (strpos($this->_formTemplate, '{hidden}')) {
            $html = str_replace('{hidden}', $this->_hiddenHtml, $html);
        } else {
            $this->_html .= $this->_hiddenHtml;
        }
        $this->_hiddenHtml = '';
        $this->_html = str_replace('{content}', $this->_html, $html);
        // add a validation script
        if ('' != ($script = $form->getValidationScript())) {
            $this->_html = $script . "\n" . $this->_html;
        }
    }
1265021
public function definition() {
        $mform = $this->_form;

        $context = context_system::instance();
        $frameworks = api::list_frameworks('shortname', 'ASC', null, null, $context);
        $options = array();
        foreach ($frameworks as $framework) {

            $options[$framework->get('id')] = $framework->get('shortname');
        }
        if (empty($options)) {
            $mform->addElement('static', 'frameworkid', '', get_string('noframeworks', 'tool_lpimportcsv'));
        } else {
            $mform->addElement('select', 'frameworkid', get_string('competencyframework', 'tool_lp'), $options);
            $mform->setType('frameworkid', PARAM_INT);
            $mform->addRule('frameworkid', null, 'required', null, 'client');
            $this->add_action_buttons(true, get_string('export', 'tool_lpimportcsv'));
        }
        $mform->setDisableShortforms();
    }
213041
public function actionResend()
    {
        /** @var \amnah\yii2\user\models\forms\ResendForm $model */

        // load post data and send email
        $model = $this->module->model("ResendForm");
        if ($model->load(Yii::$app->request->post()) && $model->sendEmail()) {

            // set flash (which will show on the current page)
            Yii::$app->session->setFlash("Resend-success", Yii::t("user", "Confirmation email resent"));
            return $this->refresh();
        }

        return $this->render("resend", compact("model"));
    }
606732
public function ItemEditForm() {
        $form=parent::ItemEditForm();
        
        if($form) {
            if($this->record && $this->record->exists()) {
                $kapostBase=KapostAdmin::config()->kapost_base_url;
                if($kapostBase[strlen($kapostBase)-1]!='/') {
                    $kapostBase.='/';
                }
                
                $form->Fields()->addFieldToTab('Root.Main', $field=ReadonlyField::create(
                                                                    'KapostRefID_linked',
                                                                    $this->record->fieldLabel('KapostRefID'),
                                                                    (!empty($kapostBase) ? '<a href="'.htmlentities($kapostBase.'posts/'.$this->record->KapostRefID).'" target="_blank">'.htmlentities($this->record->KapostRefID).'</a>':$this->record->KapostRefID)
                                                                )->setForm($form));
                $field->dontEscape=true;
                
                
                $form->Actions()->insertBefore(
                                                FormAction::create('doConvertPost', _t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'))
                                                    ->setUseButtonTag(true)
                                                    ->addExtraClass('ss-ui-action-constructive kapost-action-convert')
                                                    ->setAttribute('data-icon', 'kapost-convert')
                                                    ->setForm($form)
                                            , 'action_doDelete');
            }
            
            
            $form->addExtraClass('KapostAdmin');
        }
        
        return $form;
    }
1261767
final public static function formDefinition() : FinalizedFormObjectDefinition
    {
        $class = get_called_class();

        if (!isset(self::$definitions[$class])) {
            /** @var self $instance */
            $instance = (new \ReflectionClass($class))->newInstanceWithoutConstructor();
            $form     = new FormObjectDefinition(new ClassDefinition($instance, new \ReflectionClass(get_class($instance)), __CLASS__));
            $instance->defineForm($form);

            self::$definitions[$class] = $form->finalize();
        }

        return self::$definitions[$class];
    }
890455
function finishForm(&$form){
        global $PAGE;
        if ($form->isFrozen()){
            $this->_hiddenHtml = '';
        }
        parent::finishForm($form);
        $this->_html = str_replace('{collapsebtns}', $this->_collapseButtons, $this->_html);
        if (!$form->isFrozen()) {
            $args = $form->getLockOptionObject();
            if (count($args[1]) > 0) {
                $PAGE->requires->js_init_call('M.form.initFormDependencies', $args, true, moodleform::get_js_module());
            }
        }
    }
1190920
public function indexAction()
    {
        if ($this->util->getMaintenanceLock()->isLocked()) {
            $this->addSnippet($this->maintenanceModeSnippets);
            return;
        }

        // Make sure to return to the forward screen
        $this->currentUser->setSurveyReturn();

        $request = $this->getRequest();
        $tracker = $this->loader->getTracker();
        $form    = $tracker->getAskTokenForm(array(
            'displayOrder' => array('element', 'description', 'errors'),
            'labelWidthFactor' => 0.8
            ));

        if ($request->isPost() && $form->isValid($request->getParams())) {
            $this->_forward('forward');
            return;
        }

        $form->populate($request->getParams());
        $this->displayTokenForm($form);
    }
272003
public function definition_after_data() {

        $mform = $this->_form;

        // The default end date depends on the course format.
        $format = course_get_format((object)array('format' => get_config('moodlecourse', 'format')));

        // Check if course end date form field should be enabled by default.
        // If a default date is provided to the form element, it is magically enabled by default in the
        // MoodleQuickForm_date_time_selector class, otherwise it's disabled by default.
        if (get_config('moodlecourse', 'courseenddateenabled')) {
            $enddate = $format->get_default_course_enddate($mform, array('startdate' => 'defaults[startdate]'));
            $mform->setDefault('defaults[enddate]', $enddate);
        }
    }