mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Allow an array as a param to makeFieldReadOnly()
This commit is contained in:
parent
420041f2b6
commit
642cbdafc8
@ -671,18 +671,24 @@ class FieldList extends ArrayList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the named field into a readonly feld.
|
* Transform the named field into a readonly field.
|
||||||
*
|
*
|
||||||
* @param string|FormField
|
* @param string|array|FormField $field
|
||||||
*/
|
*/
|
||||||
public function makeFieldReadonly($field)
|
public function makeFieldReadonly($field)
|
||||||
{
|
{
|
||||||
$fieldName = ($field instanceof FormField) ? $field->getName() : $field;
|
if (!is_array($field)) {
|
||||||
$srcField = $this->dataFieldByName($fieldName);
|
$field = [$field];
|
||||||
if ($srcField) {
|
}
|
||||||
$this->replaceField($fieldName, $srcField->performReadonlyTransformation());
|
|
||||||
} else {
|
foreach ($field as $item) {
|
||||||
user_error("Trying to make field '$fieldName' readonly, but it does not exist in the list", E_USER_WARNING);
|
$fieldName = ($item instanceof FormField) ? $item->getName() : $item;
|
||||||
|
$srcField = $this->dataFieldByName($fieldName);
|
||||||
|
if ($srcField) {
|
||||||
|
$this->replaceField($fieldName, $srcField->performReadonlyTransformation());
|
||||||
|
} else {
|
||||||
|
user_error("Trying to make field '$fieldName' readonly, but it does not exist in the list", E_USER_WARNING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user