getSaveData -> getSaveValue

This commit is contained in:
Samuel Georges 2015-01-05 09:43:39 +11:00
parent 59c9146b4f
commit 0be582c42d
9 changed files with 23 additions and 11 deletions

View File

@ -87,11 +87,11 @@ abstract class FormWidgetBase extends WidgetBase
}
/**
* Process the postback data for this widget.
* Process the postback value for this widget.
* @param $value The existing value for this widget.
* @return string The new value for this widget.
*/
public function getSaveData($value)
public function getSaveValue($value)
{
return $value;
}
@ -131,4 +131,5 @@ abstract class FormWidgetBase extends WidgetBase
return [$model, $last];
}
}

View File

@ -74,7 +74,7 @@ class ColorPicker extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
return strlen($value) ? $value : null;
}

View File

@ -69,7 +69,7 @@ class DataGrid extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
return json_decode($value);
}

View File

@ -69,7 +69,7 @@ class DataTable extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
$dataSource = $this->table->getDataSource();

View File

@ -120,7 +120,7 @@ class DatePicker extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
if (!strlen($value)) {
return null;

View File

@ -195,7 +195,7 @@ class FileUpload extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
return FormField::NO_SAVE_DATA;
}

View File

@ -165,7 +165,7 @@ class RecordFinder extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
return strlen($value) ? $value : null;
}

View File

@ -141,7 +141,7 @@ class Relation extends FormWidgetBase
/**
* {@inheritDoc}
*/
public function getSaveData($value)
public function getSaveValue($value)
{
if (is_string($value) && !strlen($value)) {
return null;

View File

@ -710,7 +710,9 @@ class Form extends WidgetBase
}
$fieldName = $field->fieldName;
$defaultValue = (!$this->model->exists && $field->defaults !== '') ? $field->defaults : null;
$defaultValue = (!$this->model->exists && $field->defaults !== '')
? $field->defaults
: null;
/*
* Array field name, eg: field[key][key2][key3]
@ -806,7 +808,16 @@ class Form extends WidgetBase
$parts = Str::evalHtmlArray($field);
$dotted = implode('.', $parts);
$widgetValue = $widget->getSaveData(array_get($data, $dotted));
$widgetValue = $widget->getSaveValue(array_get($data, $dotted));
/*
* @deprecated Remove if year >= 2016
*/
if (method_exists($widget, 'getSaveData')) {
traceLog('Method getSaveData() is deprecated, use getSaveValue() instead. Found in: ' . get_class($widget), 'warning');
$widgetValue = $widget->getSaveData(array_get($data, $dotted));
}
array_set($data, $dotted, $widgetValue);
}