|
@@ -65,6 +65,7 @@ class Field extends Configurable implements FieldInterface
|
|
|
|
|
|
public function __construct($key = null, array $options = array())
|
|
public function __construct($key = null, array $options = array())
|
|
{
|
|
{
|
|
|
|
+ $this->addOption('data');
|
|
$this->addOption('trim', true);
|
|
$this->addOption('trim', true);
|
|
$this->addOption('required', true);
|
|
$this->addOption('required', true);
|
|
$this->addOption('disabled', false);
|
|
$this->addOption('disabled', false);
|
|
@@ -74,6 +75,14 @@ class Field extends Configurable implements FieldInterface
|
|
|
|
|
|
$this->key = (string)$key;
|
|
$this->key = (string)$key;
|
|
|
|
|
|
|
|
+ if (isset($options['data'])) {
|
|
|
|
+ // Populate the field with fixed data
|
|
|
|
+ // Set the property path to NULL so that the data is not
|
|
|
|
+ // overwritten by the form's data
|
|
|
|
+ $this->setData($options['data']);
|
|
|
|
+ $this->setPropertyPath(null);
|
|
|
|
+ }
|
|
|
|
+
|
|
parent::__construct($options);
|
|
parent::__construct($options);
|
|
|
|
|
|
if ($this->getOption('value_transformer')) {
|
|
if ($this->getOption('value_transformer')) {
|
|
@@ -87,7 +96,9 @@ class Field extends Configurable implements FieldInterface
|
|
$this->normalizedData = $this->normalize($this->data);
|
|
$this->normalizedData = $this->normalize($this->data);
|
|
$this->transformedData = $this->transform($this->normalizedData);
|
|
$this->transformedData = $this->transform($this->normalizedData);
|
|
|
|
|
|
- $this->setPropertyPath($this->getOption('property_path'));
|
|
|
|
|
|
+ if (!$this->getOption('data')) {
|
|
|
|
+ $this->setPropertyPath($this->getOption('property_path'));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|