Handles the creation of mock children with {@link MockDataBuilder}

@param array $data The data passed in from the form
@param CMSForm $form The Form object that was used
@return SSViewer
505925
public function doAddMockChildren($data, $form)
    {
        $parentPage = SiteTree::get()->byID((int) $data['ID']);
        if (!$parentPage) {
            return false;
        }
        
        $className = isset($data['PageType']) ? $data['PageType'] : "Page";
        $builder = new MockDataBuilder($className);
        $builder
            ->setCount((int) $data['Count'])
            ->setIncludeRelations((bool) $data['IncludeRelations'])
            ->setDownloadImages((bool) $data['DownloadImages'])
            ->setParentField("ParentID")
            ->setParentObj($parentPage);
        try {
            $ids = $builder->generate();
        } catch (Exception $e) {
            $form->sessionMessage($e->getMessage(), "bad");
            return $this->redirectBack();
        }
        $this->response->addHeader(
            'X-Status',
            _t('MockData.CREATESUCCESS', 'Created {count} mock children under {title}', array('count' => $data['Count'], 'title' => $parentPage->Title))
        );
        $this->redirect(Controller::join_links(singleton('CMSPagesController')->Link()));
        
        return $this->getResponseNegotiator()->respond($this->request);
    }
255526
protected function createComponentConfigurationForm(): Form
	{
		$form = $this->formFactory->create();
		$form->setAjaxRequest();

		$form->addGroup('cms.settings.basic');
		$form->addImageUpload('cmsLogo', 'cms.settings.logo', 'cms.settings.deleteLogo')
			->setNamespace('cms')
			->setPreview('300x100');
		$form->addCheckbox('sendNewUserPassword', 'cms.settings.sendNewUserPassword');
		$form->addCheckbox('sendChangePassword', 'cms.settings.sendChangePassword');
		$form->addCheckbox('dockbarAdvanced', 'cms.settings.dockbarAdvanced');
		$form->addSelectUntranslated('defaultLocale', 'cms.settings.defaultLocale', $this->localeService->fetch())
			->setDefaultValue($this->localeService->defaultLocaleId);
		$form->addMultiSelectUntranslated('allowedLocales', 'cms.settings.allowedLocales', $this->localeService->fetch())
			->setDefaultValue($this->localeService->allowedLocaleIds)
			->setRequired();

		$form->addGroup('cms.settings.development');
		if (!$this->tracy->isEnabled()) {
			$form->addLink('debugOn', 'cms.settings.debugOn')
				->link($this->link('debug!', true))
				->setAjaxRequest()
				->addClass('btn-success')
				->setAttribute('data-ajax-off', 'history');
		} else {
			$form->addLink('debugOff', 'cms.settings.debugOff')
				->link($this->link('debug!', false))
				->setAjaxRequest()
				->addClass('btn-danger')
				->setAttribute('data-ajax-off', 'history');
		}
		$form->addCheckbox('mailPanel', 'cms.settings.mailPanel')
			->setDefaultValue($this->configurator->mailPanel);

		$form->getRenderer()->primaryButton = $form->addSubmit('save', 'form.save');

		$form->onSuccess[] = [$this, 'configurationFormSucseeded'];

		return $form;
	}
1209512
public function doNew($data, $form)
    {
        return $this->redirect(Controller::join_links($this->gridField->Link('item'), 'new'));
    }
908413
public function buildForm(FormBuilderInterface &$builder, array $options, array $data)
    {
        $this->addStandardFormFields('contactsource', 'categories', $builder, $data);
        $this->addExtendedFormFields('contactsource', 'items', $builder, $data);
        //This is in anticipation of PR 5995 getting merged ~2.16
        if (method_exists($this, 'addCustomFormFields')) {
            $addCustomFormFields = 'addCustomFormFields';
            $this->$addCustomFormFields($this->getName(), 'export', $builder, 'mautic.core.permissions.export', ['disable' => 'mautic.core.permissions.disable'], $data);
        }
    }
2272
public function doUpdate($data, $form)
    {
        try {
            foreach ($this->Items() as $item) {
                foreach ($data as $key => $value) {
                    $sliced_key = explode("_", $key);
                    if ($sliced_key[0] == "Quantity") {
                        if (isset($item) && ($item->Key == $sliced_key[1])) {
                            if ($value > 0) {
                                ShoppingCartFactory::create()->updateItem(
                                    $item,
                                    $value
                                );
                            } else {
                                $item->delete();
                            }

                            $form->sessionMessage(
                                _t("ShoppingCart.UpdatedShoppingCart", "Shopping cart updated"),
                                ValidationResult::TYPE_GOOD
                            );
                        }
                    }
                }
            }
            ShoppingCartFactory::create()->save();
        } catch (ValidationException $e) {
            $form->sessionMessage(
                $e->getMessage()
            );
        } catch (Exception $e) {
            $form->sessionMessage(
                $e->getMessage()
            );
        }
        
        return $this->redirectBack();
    }
887116
public function tabBuilder(\samsoncms\app\material\form\Form & $form)
    {
        // If we have related structures
        if (count($form->navigationIDs)) {
            // Get all gallery additional field for material form structures
            $galleryFields = $this->query->entity(\samsoncms\api\Field::class)
                ->where('Type', 9)
                ->join('structurefield')
                ->where('structurefield_StructureID', $form->navigationIDs)
                ->exec();

            // Create tab for each additional gallery field
            foreach ($galleryFields as $field) {
                $form->tabs[] = new Gallery($this, $this->query, $form->entity, $field);
            }
        }
    }
1148598
public function renderFormAction(
        Action $action,
        Request $request,
        FormInterface $form,
        $data = null,
        array $viewParameters = []
    ): Response {
        $viewParameters = array_merge($this->getViewParameters($action, $request, $form, $data), $viewParameters);

        return $this->renderAction($action, $viewParameters);
    }
200215
public function delete($data, $form) {
		$className = $this->stat('tree_class');

		$record = DataObject::get_by_id($className, Convert::raw2sql($data['ID']));
		if($record && !$record->canDelete()) return Security::permissionFailure();
		if(!$record || !$record->ID) $this->httpError(404, "Bad record ID #" . (int)$data['ID']);
		$type = $record->ClassName;
		$record->delete();

		Session::set("FormInfo.Form_EditForm.formError.message", "Deleted $type");
		Session::set("FormInfo.Form_EditForm.formError.type", 'bad');

		$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.')));
		return $this->getResponseNegotiator()->respond(
			$this->request,
			array('currentform' => array($this, 'EmptyForm'))
		);
	}
63443
public static function registerCondForm($clz, $form) {
        assert(!empty($clz) && class_exists($clz), 'CtsDataSource is invalid');
        assert($form instanceof FormTable, get_class($form) . ' is not an instance of FormTable');
        self::$forms[ $clz ] = $form;
    }
1359482
public function submit(Form $form, array $values = []/*, array $serverParameters = []*/)
    {
        if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
            @trigger_error(sprintf('The "%s()" method will have a new "array $serverParameters = []" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
        }

        $form->setValues($values);
        $serverParameters = 2 < \func_num_args() ? func_get_arg(2) : [];

        return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles(), $serverParameters);
    }
773920
public function save($data, $form)
    {
        $errors = null;

        // Existing or new record?
        $id = empty($data['ID']) ? 0 : $data['ID'];
        if ($id) {
            $record = ChangeSet::get()->byID($id);
            if ($record && !$record->canEdit()) {
                return Security::permissionFailure($this);
            }
            if (!$record || !$record->ID) {
                $this->httpError(404, "Bad record ID #" . (int)$id);
            }
        } else {
            if (!ChangeSet::singleton()->canCreate()) {
                return Security::permissionFailure($this);
            }
            $record = ChangeSet::create();
        }

        $hasExistingName = Changeset::get()
            ->filter('Name:nocase', $data['Name'])
            ->exclude('ID', $id)
            ->count() > 0;

        if (!$hasExistingName) {
            // save form data into record
            $form->saveInto($record, true);
            $record->write();
            $this->extend('onAfterSave', $record);
            $message = _t(__CLASS__.'.SAVEDUP', 'Saved.');
            $form->setMessage($message, ValidationResult::TYPE_GOOD);
        } else {
            $nameDuplicateMsg = _t(__CLASS__ . '.ERROR_DUPLICATE_NAME', 'Name "{Name}" already exists', '', [ 'Name' => $data['Name']]);
            $errors = new ValidationResult();
            $errors->addFieldMessage('Name', $nameDuplicateMsg);
            $message = _t(__CLASS__.'.SAVEDERROR', 'Error.');
            // Need to set the form message or the field message won't show up at all
            $form->setMessage($message, ValidationResult::TYPE_ERROR);
        }

        if ($id) {
            $schemaId = Controller::join_links($this->Link('schema'), 'campaignEditForm', $id);
        } else {
            $schemaId = Controller::join_links($this->Link('schema'), 'campaignCreateForm');
        }

        // Ensure that newly created records have all their data loaded back into the form.
        $form->loadDataFrom($record);
        $extra = ['record' => ['id' => $record->ID]];
        $response = $this->getSchemaResponse($schemaId, $form, $errors, $extra);
        $response->addHeader('X-Status', rawurlencode($message));
        return $response;
    }
787134
public function gridFieldAlterAction($data, $form, HTTPRequest $request)
    {
        $data = $request->requestVars();

        // Protection against CSRF attacks
        $token = $this
            ->getForm()
            ->getSecurityToken();
        if (!$token->checkRequest($request)) {
            $this->httpError(400, _t(
                "SilverStripe\\Forms\\Form.CSRF_FAILED_MESSAGE",
                "There seems to have been a technical problem. Please click the back button, " . "refresh your browser, and try again."
            ));
        }

        $name = $this->getName();

        $fieldData = null;

        if (isset($data[$name])) {
            $fieldData = $data[$name];
        }

        $state = $this->getState(false);

        /** @skipUpgrade */
        if (isset($fieldData['GridState'])) {
            $state->setValue($fieldData['GridState']);
        }

        // Fetch the store for the "state" of actions (not the GridField)
        /** @var StateStore $store */
        $store = Injector::inst()->create(StateStore::class . '.' . $this->getName());

        foreach ($data as $dataKey => $dataValue) {
            if (preg_match('/^action_gridFieldAlterAction\?StateID=(.*)/', $dataKey, $matches)) {
                $stateChange = $store->load($matches[1]);

                $actionName = $stateChange['actionName'];

                $arguments = array();

                if (isset($stateChange['args'])) {
                    $arguments = $stateChange['args'];
                };

                $html = $this->handleAlterAction($actionName, $arguments, $data);

                if ($html) {
                    return $html;
                }
            }
        }

        if ($request->getHeader('X-Pjax') === 'CurrentField') {
            if ($this->getState()->Readonly === true) {
                $this->performDisabledTransformation();
            }
            return $this->FieldHolder();
        }

        return $form->forTemplate();
    }
593552
function submitFoundationForm($data, $form) {
		if(isset($data['SecurityID'])) {
			unset($data['SecurityID']);
		}
		Session::set('FoundationForm' . $this->ID, $data);
		
		return $this->redirect($this->Link());
	}
1053790
public function createForm($form) {
        $params = array();
        foreach ($form as $key => $value) {
            foreach ($value as $k => $v) {
                if ($key == "properties") {
                    $params["{$key}[{$k}]"] = $v;
                } else {
                    foreach ($v as $a => $b) {
                        $params["{$key}[{$k}][{$a}]"] = $b;
                    }
                }
            }
        }
        return $this->_executePostRequest('user/forms', $params);
    }
701458
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        if($this->view == 'read_only'){
            $readOnly = true;
        } else {
            $readOnly = false;
        }

        $builder->add('name', 'text', array(
            'label' => 'Name',
//            'data' => $options['data']->getName(),
            'read_only' => $readOnly,
        ));

        if($this->view != 'hide_url'){
            $builder->add('URL', 'url', array(
                'label' => 'URL',
//                'data' => $options['data']->getUrl(),
                'read_only' => $readOnly,
            ));
        }

        if($this->view == 'checkbox'){
            $builder->add('selected', 'checkbox', array(
                'label'     => 'Add "'.$options['data']->getName().'" as location',
                'required'  => true,
                'data' => true,
                'mapped' => false,
                'attr' => array(
                    'align_with_widget' => true,
                ),
            ));
        }

        $hookListener = $this->getHookListener($builder);

        // Embed hook forms.
        $builder->addEventSubscriber($hookListener);
    }
653956
public function doSaveCroppableImage($data, $form)
    {
        $link = $this->getCroppableImageObject() ? $this->getCroppableImageObject() : SaltedCroppableImage::create();
        $form->saveInto($link);
        try {
            $link->write();
        } catch (ValidationException $e) {
            $form->sessionMessage($e->getMessage(), 'bad');
            return $form->forTemplate();
        }
        $this->setValue($link->ID);
        $this->setForm($form);
        return $this->FieldHolder();
    }
802039
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->buildValuesForm($builder, $options);
        $this->buildDataForm($builder, $options);

        $builder->addEventListener(
            FormEvents::POST_SUBMIT,
            function (FormEvent $event) {
                $data = $event->getData();
                if ($data instanceof DataInterface) {
                    $data->setUpdatedAt(new \DateTime());
                }
            }
        );
    }