Updates the edit form object from AssetAdmin to provide a workaround for a bug in Secure Assets.

@param Form $form
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);
                    
                }
                
            }
            
        }
    }
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);
    }
1046711
public function edit_field_add($mform) {
        $mform->addElement('select', $this->inputname, format_string($this->field->name), $this->options);
    }
858872
public function edit_field($mform) {
        if (!$this->is_editable()) {
            return false;
        }

        $this->edit_field_add($mform);
        $this->edit_field_set_default($mform);
        $this->edit_field_set_required($mform);
        return true;
    }
518862
public function passwordFormSucceeded(Form $form, ArrayHash $values): void
	{
		try {
			$this->profile->setPassword($values->password, $values->oldPassword);
			$this->orm->persistAndFlush($this->profile);
			$this->flashNotifier->success('cms.user.passwordChanged');
		} catch (AuthenticationException $e) {
			$form->addError('cms.user.incorrectPassword');
		}
		if ($this->isAjax()) {
			$this->redrawControl('passwordForm');
		}
	}
1164902
protected function setButtonsContainer(&$form)
    {
        $form->fieldset('', function (Fieldset $fieldset) {
            $fieldset->control('button', 'cancel-button')
                    ->attributes(['type' => 'submit', 'class' => 'btn btn--md btn--default mdl-button mdl-js-button mdl-js-ripple-effect'])
                    ->value(trans('antares/foundation::label.cancel'));

            $fieldset->control('button', 'save-button')
                    ->attributes(['type' => 'submit'])
                    ->value(trans('antares/foundation::label.save'));
        });
    }
724441
public function formExtendFields($form)
    {
        /*
         * Show the username field if it is configured for use
         */
        if (
            UserSettings::get('login_attribute') == UserSettings::LOGIN_USERNAME &&
            array_key_exists('username', $form->getFields())
        ) {
            $form->getField('username')->hidden = false;
        }
    }
1250579
public function success(Form $form) : void
    {
        if ($this->presenter->isAjax())
        {
            $values = $form->getValues();

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

            try
            {
                $this->onPageManager->saveSocial($this->activePage, $values->title, $values->description);

                if ($values->image->isOk())
                {
                    $this->onPageManager->saveSocialImage($this->activePage, $values->image);
                }

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

                $this->presenter->notificationAjax(
                    'On-Page faktory',
                    'Informace pro sociální sítě byly úspěšně uloženy.',
                    'success',
                    FALSE
                );

                $this->onSave();
            }
            catch (DatabaseException|ProtectedFileException $exception)
            {
                $this->onPageManager->getConnection()->rollBack();

                $this->presenter->notificationAjax(
                    'Chyba',
                    $exception->getMessage(),
                    'error'
                );
            }
        }
    }
277768
public function done($data, $form) {
		if (!$this->data()->canEdit()) {
			return Security::permissionFailure($this);
		}
		// save stuff then reuse the edit action
		$this->savePage($this->data(), $form);

		return $this->redirect($this->data()->Link() . '?stage=Stage');
	}
637657
public function doAdd($data, Form $form) {
        $record=$this->getRecord(null);
        $form->saveInto($record);
        $record->write();
        
        $editController=singleton('CodeBank');
        $editController->setCurrentPageID($record->ID);
        
        return $this->redirect(Controller::join_links(singleton('CodeBank')->Link('show'), $record->ID));
    }
621443
public function updateSearchForm($form){
		if($this->modelIsMultiSitesAware()) {
			$managedSites = Multisites::inst()->sitesManagedByMember();

			$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
			$plural = singleton($this->owner->modelClass)->plural_name();
			if(count($source)){
				$activeSite = $this->getActiveSite();
				$form->Fields()->push(DropdownField::create(
					'SiteID', 
					"Site: ", 
					$source,
					$activeSite ? $activeSite->ID : null
				));
			}
		}
	}
1162170
public function _edit_form_after_editor() {
		$post_type = get_post_type();

		if ( ! $post_type ) {
			return;
		}

		if ( false === get_post_type_object( $post_type )->public ) {
			return;
		}

		ob_start();
		include( __DIR__ . '/view/modal.php' );
		// @codingStandardsIgnoreStart
		echo ob_get_clean();
		// @codingStandardsIgnoreEnd
	}
1635
public function editTransversalSubmit(array &$form, FormStateInterface $form_state)
    {
        if (!$this->manager->getSiteContext()->isTemporary()) {

            // @todo Generate a better token (random).
            $token  = drupal_get_token();
            $layout = $this->manager->getSiteContext()->getCurrentLayout();
            $this->manager->getSiteContext()->setToken($token);

            // Saving the layout will force it be saved in the temporary storage.
            $this->manager->getSiteContext()->getStorage()->save($layout);

            $form_state->setRedirect(
                current_path(),
                ['query' => [ContextManager::PARAM_SITE_TOKEN => $token] + drupal_get_query_parameters()]
            );
        }
    }
1137404
public function setForm($Form)
    {
        if (! is_object($Form) || ! $Form instanceof Helpers\Form) {
            throw new \InvalidArgumentException(
                'The Form Object must be a valid Helpers\Form Object'
            );
        }
        $this->Form = $Form;

        return true;
    }
625554
public function formExtendFields($form)
    {
        if ($form->getContext() == 'myaccount') {
            return;
        }

        if (!$this->user->isSuperUser()) {
            $form->removeField('is_superuser');
        }

        /*
         * Add permissions tab
         */
        $form->addTabFields($this->generatePermissionsField());

        /*
         * Mark default groups
         */
        if (!$form->model->exists) {
            $defaultGroupIds = UserGroup::where('is_new_user_default', true)->lists('id');

            $groupField = $form->getField('groups');
            $groupField->value = $defaultGroupIds;
        }
    }
1317694
protected function persistData(Form $form)
    {
        parent::persistData($form);

        $positionData = $form->get('tabs')->get('position_tab')->get('position')->getNormData();

        if ($positionData) {
            $positionData = json_decode($positionData);
            /** @var MenuItem $data */
            $data = $form->getData();

            $entityManager = $this->getDoctrine()->getEntityManager();
            /** @var NestedTreeRepository $menuItemRepo */
            $menuItemRepo = $this->getDoctrine()->getRepository($this->getEntityName());

            $positionData->parent = intval($positionData->parent) ? ($positionData->parent) : 0;

            $data->setParent(null);
            if (intval($positionData->parent) > 0) {
                $data->setParent($entityManager->getReference($this->getEntityName(), $positionData->parent));
            }

            $menuItemRepo->persistAsFirstChild($data);
            if ($positionData->position) {
                $menuItemRepo->moveDown($data, $positionData->position);
            }

            $entityManager->flush();
        }
    }
1006090
public function doAddNew($data, $form)
    {
        $obj = Object::create($this->addNewClass);
        if (!$obj->canCreate()) {
            return Security::permissionFailure(Controller::curr(), "You don't have permission to create this object");
        }
        $form->saveInto($obj);

        try {
            $obj->write();
        } catch (Exception $e) {
            $form->setMessage($e->getMessage(), 'error');
            return $form->forTemplate();
        }

        $callback = $this->sourceCallback;
        $items = $callback($obj);
        $this->owner->setSource($items);

        // if this field is a multiselect field, we add the new Object ID to the existing
        // options that are selected on the field then set that as the value
        // otherwise we just set the new Object ID as the value
        if (isset($data['existing'])) {
            $existing = $data['existing'];
            $value = explode(',', $existing);
            $value[] = $obj->ID;
        } else {
            $value = $obj->ID;
        }

        $this->owner->setValue($value);
        // NOTE(Jake): Below line causes cyclic issues, I assume it's not necessary.
        //$this->owner->setForm($form);
        return $this->owner->FieldHolder();
    }