Any data processing needed before the form is displayed
(needed to set up draft areas for editor and filemanager elements)
@param array $defaultvalues
19275
public function data_preprocessing(&$defaultvalues) {
        global $DB;

        $ctx = null;
        if ($this->current && $this->current->coursemodule) {
            $cm = get_coursemodule_from_instance('assign', $this->current->id, 0, false, MUST_EXIST);
            $ctx = context_module::instance($cm->id);
        }
        $assignment = new assign($ctx, null, null);
        if ($this->current && $this->current->course) {
            if (!$ctx) {
                $ctx = context_course::instance($this->current->course);
            }
            $course = $DB->get_record('course', array('id'=>$this->current->course), '*', MUST_EXIST);
            $assignment->set_course($course);
        }

        $draftitemid = file_get_submitted_draft_itemid('introattachments');
        file_prepare_draft_area($draftitemid, $ctx->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA,
                                0, array('subdirs' => 0));
        $defaultvalues['introattachments'] = $draftitemid;

        $assignment->plugin_data_preprocessing($defaultvalues);
    }
853888
protected function setDefaultDataTypes()
    {
        foreach ($this->_params as $key => $value) {
            switch (gettype($value)) {
                case "boolean":
                    $this->_types[$key] = 'boolean';
                    break;
                case "integer":
                    $this->_types[$key] = 'integer';
                    break;
                case "double":
                    $this->_types[$key] = 'float';
                    break;
                case "string":
                    $this->_types[$key] = 'string';
                    break;
                case "array":
                    $this->_types[$key] = 'array';
                    break;
                default:
                    $this->_types[$key] = null;
                    break;
            }
        }
    }
1115624
public function initDefaultProperties()
    {
        if (isset($this->schema) && $this->setPropertyDefaultValue($this->schema)) {
            $this->property_value = $this->schema->default;
        }
    }
952144
public function postProcessFormValues(array $formValues)
    {
        if (empty($formValues['defaultDeploymentPath']) === false) {
            $this->distributionSettings = Arrays::setValueByPath(
                $this->distributionSettings,
                'Lightwerk.SurfCaptain.frontendSettings.defaultDeploymentPath',
                $formValues['defaultDeploymentPath']
            );
        }
        if (empty($formValues['defaultUser']) === false) {
            $this->distributionSettings = Arrays::setValueByPath(
                $this->distributionSettings,
                'Lightwerk.SurfCaptain.frontendSettings.defaultUser',
                $formValues['defaultUser']
            );
        }
        $this->configurationSource->save(
            FLOW_PATH_CONFIGURATION . ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
            $this->distributionSettings
        );
    }
219145
public void setDefaultValue(T defaultValue, ProcessCase[] cases) {
        this.defaultValue = OptionalProcessCase.of(defaultValue, cases);
    }
594410
public function configurationFormSucseeded(Form $form, ArrayHash $values): void
	{
		$this->localeService->default = $values->defaultLocale;
		$this->localeService->allowed = $values->allowedLocales;
		unset($values->defaultLocale, $values->allowedLocales);

		foreach ($values as $name => $value) {
			$this->configurator->$name = $value;
		}
		$this->flashNotifier->success('cms.settings.settingsSaved');

		if ($this->isAjax()) {
			$this->redrawControl('configuration');
		} else {
			$this->redirect('default');
		}
	}
557161
protected function _setDefaultPlaceholderValue($value)
    {
        if (!is_null($value)) {
            $value = $this->_normalizeStringable($value);
        }

        $this->defaultPlaceholderValue = $value;
    }
1073309
public function addElementDefaultValue($elementIdentifier, $defaultValue)
    {
        $this->elementDefaultValues = Arrays::setValueByPath($this->elementDefaultValues, $elementIdentifier, $defaultValue);
    }
595162
public static function defaultValues(array $values, array &$array)
    {
        foreach ($values as $name => $value) {
            self::defaultValue($name, $value, $array);
        }
    }
884502
public function Save($FormPostValues) {
      $Session = Gdn::Session();
      
      // Define the primary key in this model's table.
      $this->DefineSchema();
      
      // Add & apply any extra validation rules:      
      $this->Validation->ApplyRule('Body', 'Required');
      $MaxCommentLength = Gdn::Config('Vanilla.Comment.MaxLength');
      if (is_numeric($MaxCommentLength) && $MaxCommentLength > 0) {
         $this->Validation->SetSchemaProperty('Body', 'Length', $MaxCommentLength);
         $this->Validation->ApplyRule('Body', 'Length');
      }
      
      // Get the DraftID from the form so we know if we are inserting or updating.
      $DraftID = ArrayValue('DraftID', $FormPostValues, '');
      $Insert = $DraftID == '' ? TRUE : FALSE;
      
      // Remove the discussionid from the form value collection if it's empty
      if (array_key_exists('DiscussionID', $FormPostValues) && $FormPostValues['DiscussionID'] == '')
         unset($FormPostValues['DiscussionID']);
      
      if ($Insert) {
         // If no categoryid is defined, grab the first available.
         if (ArrayValue('CategoryID', $FormPostValues) === FALSE)
            $FormPostValues['CategoryID'] = $this->SQL->Get('Category', '', '', 1)->FirstRow()->CategoryID;
            
      }
      // Add the update fields because this table's default sort is by DateUpdated (see $this->Get()).
      $this->AddInsertFields($FormPostValues);
      $this->AddUpdateFields($FormPostValues);
      
      // Remove checkboxes from the fields if they were unchecked
      if (ArrayValue('Announce', $FormPostValues, '') === FALSE)
         unset($FormPostValues['Announce']);

      if (ArrayValue('Closed', $FormPostValues, '') === FALSE)
         unset($FormPostValues['Closed']);

      if (ArrayValue('Sink', $FormPostValues, '') === FALSE)
         unset($FormPostValues['Sink']);
         
      // Validate the form posted values
      if ($this->Validate($FormPostValues, $Insert)) {
         $Fields = $this->Validation->SchemaValidationFields(); // All fields on the form that relate to the schema
         $DraftID = intval(ArrayValue('DraftID', $Fields, 0));
         
         // If the post is new and it validates, make sure the user isn't spamming
         if ($DraftID > 0) {
            // Update the draft
            $Fields = RemoveKeyFromArray($Fields, 'DraftID'); // Remove the primary key from the fields for saving
            $this->SQL->Put($this->Name, $Fields, array($this->PrimaryKey => $DraftID));
         } else {
            // Insert the draft
            unset($Fields['DraftID']);
            $DraftID = $this->SQL->Insert($this->Name, $Fields);
            $this->UpdateUser($Session->UserID);
         }
      }
      
      return $DraftID;
   }
935771
public function plugin_data_preprocessing(&$defaultvalues) {
        foreach ($this->submissionplugins as $plugin) {
            if ($plugin->is_visible()) {
                $plugin->data_preprocessing($defaultvalues);
            }
        }
        foreach ($this->feedbackplugins as $plugin) {
            if ($plugin->is_visible()) {
                $plugin->data_preprocessing($defaultvalues);
            }
        }
    }
878019
public function applyDefaultValues()
    {
        $this->config_displayerrors = 'Off';
        $this->config_bypasscache = 'Off';
        $this->config_minifymarkup = 'Off';
        $this->config_debugmode = 'Off';
        $this->config_maintenancemode = 'Off';
        $this->config_gzipscripts = 'Off';
        $this->config_rewriteurl = 'Off';
    }
1094038
protected function setupDefaultOptions()
    {
        $defaultOptions = [
            'overwriteInitial' => false,
            'initialPreviewAsData' => true,
            'browseLabel' => trans('admin.browse'),
            'showRemove' => false,
            'showUpload' => false,
//            'initialCaption'       => $this->initialCaption($this->value),
            'deleteExtraData' => [
                $this->formatName($this->column) => static::FILE_DELETE_FLAG,
                static::FILE_DELETE_FLAG => '',
                '_token' => csrf_token(),
                '_method' => 'PUT',
            ],
        ];

        if ($this->form instanceof Form) {
            $defaultOptions['deleteUrl'] = $this->form->resource().'/'.$this->form->model()->getKey();
        }

        $this->options($defaultOptions);
    }
602302
protected function setupDefaultOptions()
    {
        $defaults = [
            'overwriteInitial'     => false,
            'initialPreviewAsData' => true,
            'browseLabel'          => trans('admin.browse'),
            'cancelLabel'          => trans('admin.cancel'),
            'showRemove'           => false,
            'showUpload'           => false,
            'dropZoneEnabled'      => false,
            'deleteExtraData'      => [
                $this->formatName($this->column) => static::FILE_DELETE_FLAG,
                static::FILE_DELETE_FLAG         => '',
                '_token'                         => csrf_token(),
                '_method'                        => 'PUT',
            ],
        ];

        if ($this->form instanceof Form) {
            $defaults['deleteUrl'] = $this->form->resource().'/'.$this->form->model()->getKey();
        }

        $defaults = array_merge($defaults, ['fileActionSettings' => $this->fileActionSettings]);

        $this->options($defaults);
    }
4154
public function getScriptInitialization($defaultValues = false)
    {
        $scriptContent = '';
        foreach ($this->variables as $variable) {
            $scriptContent .= $variable->getScriptDeclaration()."\n";
            if ($defaultValues) {
                $scriptContent .= $variable->getScriptValueSet()."\n";
            }
        }

        $scriptContent .= $this->checkVariable->getScriptDeclaration()."\n";
        $scriptContent .= $this->checkOldVariable->getScriptDeclaration()."\n";
        $scriptContent .= $this->checkWindow->getScriptDeclaration()."\n";
        $scriptContent .= "declare check_original = ".$this->checkWindow->getInitialValue().";\n";

        if ($defaultValues) {
            $scriptContent .= $this->checkVariable->getScriptValueSet()."\n";
            $scriptContent .= $this->checkOldVariable->getScriptValueSet()."\n";
            $scriptContent .= $this->checkWindow->getScriptValueSet()."\n";
        }

        return $scriptContent;
    }
644201
public function initDefaultProperties()
    {
        if (!empty($this->schema->properties)) {
            foreach ($this->schema->properties as $property_name => $property) {
                if ($this->setPropertyDefaultValue($property)) {
                    $this->property_values->$property_name = $this->getFactory()->create($property, $this->schema_path);
                }
            }
        }
    }
197371
static public function valueDeleteExtender(RecordValue $valueContainer, $deleteFiles) {
        if ($deleteFiles) {
            /** @var FileColumn $column */
            $column = $valueContainer->getColumn();
            $fileConfig = $column->getConfiguration();
            $pkValue = $valueContainer->getRecord()->getPrimaryKeyValue();
            \File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
            if ($pkValue) {
                \File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
            }
        }
    }