Set field default values before displaying a form builder
Created 6 years ago by edsterTrying to set a few fields default values dynamically. However I can't figure out where in the build process or how to set them.
Tried using $builder->getForm()->setValue(key, value)
but it doesn't work.
edster
—
6 years ago
@ryanthompson are you refering to on the fields?
Doing something like this doesn't work
$fields = $checkoutBuilder->getFields();
$fields['lot'] = [
'default_value' => $this->unit['lot'],
'readOnly' => TRUE
];
but doing the below does?
$fields = $checkoutBuilder->getFields();
$fields['lot'] = [
'value' => $this->unit['lot'],
'readOnly' => TRUE
];
ryanthompson
—
6 years ago
It's a config
value: https://pyrocms.com/documentation/text-field-type/2.2/introduction/configuration
But it is supported across the board by core functionality - so it doesn't technically "live" in the FTs.
Use the
default_value
config (pre-build)