Generate the form actions for the UserDefinedForm. You
can manipulate these by using {@link updateFormActions()} on
a decorator.

@todo Make form actions editable via their own field editor.

@return FieldList
762376
public function getFormActions()
    {
        $submitText = ($this->controller->SubmitButtonText)
            ? $this->controller->SubmitButtonText
            : _t('SilverStripe\\UserForms\\Model\\UserDefinedForm.SUBMITBUTTON', 'Submit');
        $clearText = ($this->controller->ClearButtonText)
            ? $this->controller->ClearButtonText
            : _t('SilverStripe\\UserForms\\Model\\UserDefinedForm.CLEARBUTTON', 'Clear');

        $actions = FieldList::create(FormAction::create('process', $submitText));

        if ($this->controller->ShowClearButton) {
            $actions->push(FormAction::create('clearForm', $clearText)->setAttribute('type', 'reset'));
        }

        $this->extend('updateFormActions', $actions);
        $actions->setForm($this);
        return $actions;
    }
392413
public function definition() {
        global $PAGE, $USER;
        $mform = $this->_form;

        if (empty($this->_customdata['userids']) || !is_array($this->_customdata['userids'])) {
            throw new \moodle_exception('missingparam', 'error', '', 'userids');
        }
        if (empty($this->_customdata['versionids']) || !is_array($this->_customdata['versionids'])) {
            throw new \moodle_exception('missingparam', '', '', 'versionids');
        }
        $action = $this->_customdata['action'];
        $userids = clean_param_array($this->_customdata['userids'], PARAM_INT);
        $versionids = clean_param_array($this->_customdata['versionids'], PARAM_INT);
        $usernames = $this->validate_and_get_users($versionids, $userids, $action);
        $versionnames = $this->validate_and_get_versions($versionids);

        foreach ($usernames as $userid => $name) {
            $mform->addElement('hidden', 'userids['.$userid.']', $userid);
            $mform->setType('userids['.$userid.']', PARAM_INT);
        }

        foreach ($versionnames as $versionid => $name) {
            $mform->addElement('hidden', 'versionids['.$versionid.']', $versionid);
            $mform->setType('versionids['.$versionid.']', PARAM_INT);
        }

        $mform->addElement('hidden', 'returnurl');
        $mform->setType('returnurl', PARAM_LOCALURL);
        $useracceptancelabel = (count($usernames) > 1) ? get_string('acceptanceusers', 'tool_policy') :
                get_string('user');
        $mform->addElement('static', 'user', $useracceptancelabel, join(', ', $usernames));
        $policyacceptancelabel = (count($versionnames) > 1) ? get_string('acceptancepolicies', 'tool_policy') :
                get_string('policydochdrpolicy', 'tool_policy');
        $mform->addElement('static', 'policy', $policyacceptancelabel, join(', ', $versionnames));

        if ($action === 'revoke') {
            $mform->addElement('static', 'ack', '', get_string('revokeacknowledgement', 'tool_policy'));
            $mform->addElement('hidden', 'action', 'revoke');
        } else if ($action === 'accept') {
            $mform->addElement('static', 'ack', '', get_string('acceptanceacknowledgement', 'tool_policy'));
            $mform->addElement('hidden', 'action', 'accept');
        } else if ($action === 'decline') {
            $mform->addElement('static', 'ack', '', get_string('declineacknowledgement', 'tool_policy'));
            $mform->addElement('hidden', 'action', 'decline');
        } else {
            throw new \moodle_exception('invalidaccessparameter');
        }

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

        if (count($usernames) == 1 && isset($usernames[$USER->id])) {
            // No need to display the acknowledgement if the users are giving/revoking acceptance on their own.
            $mform->removeElement('ack');
        }

        $mform->addElement('textarea', 'note', get_string('acceptancenote', 'tool_policy'));
        $mform->setType('note', PARAM_NOTAGS);

        if (!empty($this->_customdata['showbuttons'])) {
            if ($action === 'revoke') {
                $this->add_action_buttons(true, get_string('irevokethepolicy', 'tool_policy'));
            } else if ($action === 'accept') {
                $this->add_action_buttons(true, get_string('iagreetothepolicy', 'tool_policy'));
            } else if ($action === 'decline') {
                $this->add_action_buttons(true, get_string('declinethepolicy', 'tool_policy'));
            }
        }

        $PAGE->requires->js_call_amd('tool_policy/policyactions', 'init');
    }
434051
public function updateForm()
    {
        if ($userDefinedForm = $this->owner->getController()->data()) {
            
            if ($userDefinedForm->EnableSpamGuard) {
                $this->owner->enableSpamProtection();
            }
            
        }
    }
189410
protected function getFormFields()
    {
        $fields = FieldList::create();

        $controller = $this->getController();
        $backURL = $controller->getBackURL()
            ?: $controller->getReturnReferer();

        // Protect against infinite redirection back to the logout URL after logging out
        if (!$backURL || Director::makeRelative($backURL) === $controller->getRequest()->getURL()) {
            $backURL = Director::baseURL();
        }

        $fields->push(HiddenField::create('BackURL', 'BackURL', $backURL));

        return $fields;
    }
114472
public function getFormOptions()
    {
        $submit = ($this->SubmitButtonText) ? $this->SubmitButtonText : _t(__CLASS__.'.SUBMITBUTTON', 'Submit');
        $clear = ($this->ClearButtonText) ? $this->ClearButtonText : _t(__CLASS__.'.CLEARBUTTON', 'Clear');

        $options = FieldList::create(
            TextField::create('SubmitButtonText', _t(__CLASS__.'.TEXTONSUBMIT', 'Text on submit button:'), $submit),
            TextField::create('ClearButtonText', _t(__CLASS__.'.TEXTONCLEAR', 'Text on clear button:'), $clear),
            CheckboxField::create('ShowClearButton', _t(__CLASS__.'.SHOWCLEARFORM', 'Show Clear Form Button'), $this->ShowClearButton),
            CheckboxField::create('EnableLiveValidation', _t(__CLASS__.'.ENABLELIVEVALIDATION', 'Enable live validation')),
            CheckboxField::create('DisplayErrorMessagesAtTop', _t(__CLASS__.'.DISPLAYERRORMESSAGESATTOP', 'Display error messages above the form?')),
            CheckboxField::create('DisableCsrfSecurityToken', _t(__CLASS__.'.DISABLECSRFSECURITYTOKEN', 'Disable CSRF Token')),
            CheckboxField::create('DisableAuthenicatedFinishAction', _t(__CLASS__.'.DISABLEAUTHENICATEDFINISHACTION', 'Disable Authentication on finish action'))
        );

        $this->extend('updateFormOptions', $options);

        return $options;
    }
293283
public function editUserAction()
    {
        if(!$this->identity()) {
          return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
      
        try {
            $id = (int) $this->params()->fromRoute('id', 0);
    
            if ($id == 0) {
                $this->flashMessenger()->addErrorMessage($this->getTranslatorHelper()->translate('User ID invalid'));
                return $this->redirect()->toRoute('user-admin');
            }
            
            $entityManager = $this->getEntityManager();
            $user = $entityManager->getRepository('CsnUser\Entity\User')->find($id);
            
            $form = $this->getUserFormHelper()->createUserForm($user, 'EditUser');
            
            $form->setAttributes(array(
                'action' => $this->url()->fromRoute('user-admin', array('action' => 'edit-user', 'id' => $id)),
            ));
              	
            $request = $this->getRequest();
            if ($request->isPost()) {
                $form->setValidationGroup('username', 'email', 'firstName', 'lastName', 'language', 'state', 'role', 'question', 'answer', 'csrf');
                $form->setData($request->getPost());
                if ($form->isValid()) {
                    $entityManager->persist($user);
                    $entityManager->flush();
                    $this->flashMessenger()->addSuccessMessage($this->getTranslatorHelper()->translate('User Updated Successfully'));
                    return $this->redirect()->toRoute('user-admin');
                }
            }  
        }      
        catch (\Exception $e) {
            return $this->getServiceLocator()->get('csnuser_error_view')->createErrorView(
                $this->getTranslatorHelper()->translate('Something went wrong during update user process! Please, try again later.'),
                $e,
                $this->getOptions()->getDisplayExceptions(),
                false
            );
        }
        
        $viewModel = new ViewModel(array(
            'form' => $form,
            'headerLabel' => $this->getTranslatorHelper()->translate('Edit User').' - '.$user->getDisplayName(),
        ));
        $viewModel->setTemplate('csn-user/admin/edit-user-form');
        return $viewModel;
    }
79782
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            "Root.Main",
            array(
                TextareaField::create(
                    'Title'
                )->setRows(1),
                HTMLEditorField::create(
                    'Content'
                )
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
965369
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Style Fields:
        
        $fields->addFieldToTab(
            'Root.Style',
            FieldSection::create(
                'ButtonStyle',
                $this->fieldLabel('ButtonStyle'),
                [
                    DropdownField::create(
                        'ButtonSize',
                        $this->fieldLabel('ButtonSize'),
                        $this->getButtonSizeOptions()
                    ),
                    DropdownField::create(
                        'ButtonAnnotation',
                        $this->fieldLabel('ButtonAnnotation'),
                        $this->getButtonAnnotationOptions()
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
287373
public function AddPackageForm() {
        $sng=singleton('SnippetPackage');
        
        $fields=new FieldList(
                            new TabSet('Root',
                                    new Tab('Main', _t('PackageSelectionField.MAIN', '_Main'),
                                            new TextField('Title', _t('PackageSelectionField.TITLE', '_Title'), null, 300)
                                        )
                                )
                        );
        
        $actions=new FieldList(
                                FormAction::create('doAddPackage', _t('PackageSelectionField.CREATE', '_Create'))
                                                    ->addExtraClass('ss-ui-action-constructive')
                                                    ->setAttribute('data-icon', 'accept')
                                                    ->setUseButtonTag(true)
                            );
        
        $validator=new RequiredFields(
                                    'Title'
                                );
        
        return Form::create($this, 'AddPackageForm', $fields, $actions, $validator)
                            ->addExtraClass('member-profile-form')
                            ->setFormAction($this->Link('AddPackageForm'));
    }
493625
public function newAction()
    {
        $entity = new MediaType();
        $form   = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
460283
public function updateAction()
    {
        $this->checkAuth(AdminResources::PRODUCT, [], AccessManager::UPDATE);

        $baseForm = $this->createForm(ApiForm::PRODUCT_SALE_ELEMENTS, "form", [], [
            "validation_groups" => ["update", "Default"],
            'csrf_protection' => false,
            "cascade_validation" => true,
            "method" => "PUT",
        ]);

        $baseForm->getFormBuilder()
            ->addEventListener(
                FormEvents::PRE_SUBMIT,
                [$this, "loadProductSaleElements"],
                192
            );

        $updatedId = array();

        $con = Propel::getConnection(ProductSaleElementsTableMap::DATABASE_NAME);
        $con->beginTransaction();

        try {
            $form = $this->validateForm($baseForm);

            $entries = $form->getData();

            foreach ($entries["pse"] as $entry) {
                $this->processUpdateAction(
                    $entry,
                    $pse = ProductSaleElementsQuery::create()->findPk($entry["id"]),
                    $pse->getProduct()
                );

                $updatedId[] = $pse->getId();
            }

            $con->commit();
        } catch (\Exception $e) {
            $con->rollBack();

            return new JsonResponse(["error" => $e->getMessage()], 500);
        }

        return new JsonResponse(
            $this->getProductSaleElements(
                array_merge(
                    $this->getRequest()->query->all(),
                    [
                        "id" => implode(",", $updatedId),
                        "limit" => \count($updatedId),
                    ]
                )
            ),
            201
        );
    }
55779
public function getFormFields()
    {
        $fields = new UserFormsFieldList();
        $target = $fields;

        foreach ($this->controller->data()->Fields() as $field) {
            $target = $target->processNext($field);
        }
        $fields->clearEmptySteps();
        $this->extend('updateFormFields', $fields);
        $fields->setForm($this);
        return $fields;
    }
411128
public function getWorkflowFields()
    {
        $action    = $this->CurrentAction();
        $options   = $this->validTransitions();
        $wfOptions = $options->map('ID', 'Title', ' ');
        $fields    = new FieldList();

        $fields->push(new HeaderField('WorkflowHeader', $action->Title));

        $fields->push(HiddenField::create('TransitionID', ''));
        // Let the Active Action update the fields that the user can interact with so that data can be
        // stored for the workflow.
        $action->updateWorkflowFields($fields);
        $action->invokeWithExtensions('updateWorkflowFields', $fields);
        return $fields;
    }
807700
public static function generate_filters()
	{
		if (static::$builder === null)
		{
			static::setBuilder(new Basic);
		}

		$form = [];

		// Loop through and add all fields
		foreach (static::list_properties() as $field => $config)
		{
			$form[] = static::generateInput($field, $config);
		}

		return $form;
	}
74092
public function buildTemplateAction()
    {
        $action = [
            'type' => ActionType::POSTBACK,
            'label' => $this->label,
            'data' => $this->data,
        ];

        if (isset($this->displayText)) {
            // If text is set, append extend field.
            $action['displayText'] = $this->displayText;
        }

        return $action;
    }
604692
public function AddNewForm()
    {
        $action    = FormAction::create('doAddNew', _t('QUICKADDNEW.Add', 'Add'))->setUseButtonTag('true');

        if (!$this->isFrontend) {
            $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept');
        }

        $actions = FieldList::create($action);
        $form = Form::create($this->owner, 'AddNewForm', $this->addNewFields, $actions, $this->addNewRequiredFields);

        $this->owner->extend('updateQuickAddNewForm', $form);

        return $form;
    }
701721
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            "Root.Main",
            array(
                DropdownField::create(
                    'FormPageID',
                    'Select a page',
                    UserDefinedForm::get()->map('ID', 'Title')
                )
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }