Alter a form's values recursively according to its fields.

@param  Form  $form
@param  array $values
@return void
491089
public function alterFieldValues(Form $form, array &$values)
    {
        // Alter the form itself
        $form->alterFieldValues($values);

        // Alter the form's child forms recursively
        foreach ($form->getFields() as $name => $field) {
            if (method_exists($field, 'alterFieldValues')) {
                $fullName = $this->transformToDotSyntax($name);

                $subValues = (array) Arr::get($values, $fullName);
                $field->alterFieldValues($subValues);
                Arr::set($values, $fullName, $subValues);
            }
        }
    }
1138479
public function forgottenPasswordFormSucceeded(Form $form, ArrayHash $values): void
	{
		$value = $values->usernameOrEmail;
		$user = $this->orm->users->getByUsername($value);
		if (!$user) {
			$user = $this->orm->users->getByEmail($value);
			if (!$user) {
				$form->addError('cms.user.incorrectUsernameOrEmail');
				$session = $this->getSession('cms/forgottenPassword');
				if (isset($session->count)) {
					$session->count++;
				} else {
					$session->setExpiration('1 hours');
					$session->count = 1;
				}
				$this->actionForgottenPassword();
				return;
			}
		}

		$hash = $this->hasher->hash(Random::generate());

		$session = $this->getSession('cms/restorePassword');
		$session->setExpiration('1 hours');
		$session->$hash = $user->email;

		$this->mailer->sendRestorePassword($user->email, $hash);
		$this->flashNotifier->info('cms.user.mailToRestorePasswordSent');
		$this->redirect(":{$this->module}:Sign:in");
	}
674323
private function beforePut(array &$values): void {
    $keys = array_keys($values);

    foreach($keys as &$column) {
      if(array_key_exists($column, $this->to_db)) {
        $column = $this->to_db[$column];
      }
    }

    unset($column);

    $values = array_combine($keys, array_values($values));
  }
42963
protected function processValues()
    {
        $form = $this->getForm();
        $data = &$form->getFormData();

        if (isset($data[$this->id])) {
            if (is_array($data[$this->id])) {
                $this->values = $data[$this->id];
            } elseif ($data[$this->id] != '') {
                $this->values = array($data[$this->id]);
            } else {
                $this->values = array();
            }
        } else {
            $this->values = array();
        }
    }
853601
public FormAction setValuesInForm(Form form) {
		FormAction formAction = new FormAction();
		form.setFormAction(formAction);
		this.forms.add(form);
		return formAction;
	}
1085496
protected function apply_current_section( Form $form ) {
		if ( count( $this->sections ) === 0 ) {
			return;
		}

		// Make sure we don't have any active section before.
		foreach ( $this->sections as $section ) {
			$section->options['active'] = false;
		}

		$current = $this->current_section_in_cookie( $form->get_id() );

		if ( ! $current && $form->get_config()->has_option( 'active_section' ) ) {
			$current = $form->get_config()->get_option( 'active_section' );
		}

		// Use first section as fallback.
		if ( ! $current || ! isset( $this->sections[ $current ] ) ) {
			$current = Arr::first( array_keys( $this->sections ) );
		}

		if ( $section = $this->get_section( $current ) ) {
			$section->options['active'] = true;
		}
	}
1039821
private function setSuccessfulControlValues(array $formValues, $fields)
    {
        foreach ($fields as $key => $values) {
            if (isset($formValues[$key])) {
                if ($values['type'] === 'float') {
                    // We allow ',' and '.' as decimal point and need '.' internally
                    $formValues[$key] = str_replace(',', '.', $formValues[$key]);
                }
            } else {
                if ($values['type'] === 'select' && isset($values['multiple']) && $values['multiple'] === true) {
                    $formValues[$key] = [];
                } elseif ($values['type'] === 'checkbox') {
                    $formValues[$key] = 0;
                } elseif ($values['type'] === 'repeater' || $values['type'] === 'block') {
                    $formValues[$key] = [];
                }
            }
        }

        return $formValues;
    }
451508
public function setFields($values)
    {
        foreach ($values as $field => $value) {
            $this->_setFieldValue($field, $value);
        }
    }
834300
public function SetFormValue($FieldName, $Value = NULL) {
      $this->FormValues();
      if (is_array($FieldName))
         $this->_FormValues = array_merge($this->_FormValues, $FieldName);
      else
         $this->_FormValues[$FieldName] = $Value;
   }
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);
                    
                }
                
            }
            
        }
    }
1020797
public function notify(Form $form = null, array $values = null)
    {
        //if define form in parameters
        if ($form) {
            $this->form = $form;
        }

        //if define values in parameters
        if ($values) {
            $this->setValues($values);
        }

        // iterate events
        foreach ($this->events as $eventIndex => $event) {
            // save index event
            $this->eventIndex = $eventIndex;

            // check instance of event
            if ($event instanceof IEvent) {
                $event->update($this, $this->values);
            } else {
                throw new EventException(get_class($event) . ' is not implements of ' . IEvent::class);
            }
        }
    }
421762
public function alterValid(Form $form, Form $mainForm, &$isValid)
    {
        // Alter the form itself
        $messages = $form->alterValid($mainForm, $isValid);

        // Add messages to the existing Bag
        if ($messages) {
            $messageBag = $mainForm->getValidator()->getMessageBag();
            $this->appendMessagesWithPrefix($messageBag, $form->getName(), $messages);
        }

        // Alter the form's child forms recursively
        foreach ($form->getFields() as $name => $field) {
            if (method_exists($field, 'alterValid')) {
                $field->alterValid($mainForm, $isValid);
            }
        }
    }
466970
protected function assignPropertyValues(array $values)
    {
        foreach ($values as $property => $value) {
            if (property_exists($this, $property)) {
                $this->{$property} = $value;
            }
        }
    }
980588
public function submitForm(array $values)
    {
        $this->value = isset($values[$this->name]) ? $values[$this->name] : null;
    }
583715
private function setFormName() : void
    {
        $this->key = 'form_' . $this->name . '_' . bin2hex(random_bytes(16));

        // Form key must be unique
        if (isset($_SESSION[$this->key])) {
            $this->setFormName();
        }

        // Remove potential previous form with same name from session
        $prev_form_keys = preg_grep('/^form_' . preg_quote($this->name, '/') . '_[a-f0-9]+$/', array_keys($_SESSION));
        array_map(function ($key) {
            unset($_SESSION[$key]);
        }, $prev_form_keys);

        // Save the new form
        $_SESSION[$this->key] = [];
    }
838533
public function setFields()
    {
        foreach ($this->field_associations as $form_field => $model_field) {
            $this->form->set($form_field, $model_field->get());
        }
    }
1172401
private function renderForm($form, $data = [])
    {
        // Check for tag name
        if ($form->tagName != 'form') {
            return $this;
        }

        // Set form values
        FormHelper::setValues($this->getHTMLHandler(), $form, $data['values']);

        return $this;
    }