function ConfigTarget::fromString
Same name in other branches
- 10 core/lib/Drupal/Core/Form/ConfigTarget.php \Drupal\Core\Form\ConfigTarget::fromString()
Creates a ConfigTarget object.
Parameters
string $target: The name of the config object, and property path, being read from or written to, in the form `CONFIG_NAME:PROPERTY_PATH`. For example, `system.site:page.front`.
string|null $fromConfig: (optional) A callback which should transform the value loaded from config before it gets displayed by the form. If NULL, no transformation will be done. The callback will receive all of the values loaded from config as separate arguments, in the order specified by $this->propertyPaths. Defaults to NULL.
string|null $toConfig: (optional) A callback which should transform the value submitted by the form before it is set in the config object. If NULL, no transformation will be done. The callback will receive the value submitted through the form; if this object is targeting multiple property paths, the value will be an array of the submitted values, keyed by property path, and must return an array with the transformed values, also keyed by property path. The callback will receive the form state object as its second argument. Defaults to NULL.
Return value
self A ConfigTarget instance.
3 calls to ConfigTarget::fromString()
- ConfigFormBase::doStoreConfigMap in core/
lib/ Drupal/ Core/ Form/ ConfigFormBase.php - Helper method for #after_build callback ::storeConfigKeyToFormElementMap().
- ConfigFormBase::loadDefaultValuesFromConfig in core/
lib/ Drupal/ Core/ Form/ ConfigFormBase.php - Process callback to recursively load default values from #config_target.
- ConfigTarget::fromForm in core/
lib/ Drupal/ Core/ Form/ ConfigTarget.php - Gets the config target object for an element from a form array.
File
-
core/
lib/ Drupal/ Core/ Form/ ConfigTarget.php, line 127
Class
- ConfigTarget
- Represents the mapping of a config property to a form element.
Namespace
Drupal\Core\FormCode
public static function fromString(string $target, ?string $fromConfig = NULL, ?string $toConfig = NULL) : self {
[
$configName,
$propertyPath,
] = explode(':', $target, 2);
return new self($configName, $propertyPath, $fromConfig, $toConfig);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.