Widgets can now state that they contribute no data when the form is saved
Applied to FileUpload.php
This commit is contained in:
parent
f3c6260c3e
commit
8291dbf4d3
|
|
@ -37,6 +37,11 @@ abstract class FormWidgetBase extends WidgetBase
|
|||
*/
|
||||
public $previewMode = false;
|
||||
|
||||
/**
|
||||
* @var int Value returned when the widget should not contribute any save data.
|
||||
*/
|
||||
const NO_SAVE_DATA = -1;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param $controller Controller Active controller object.
|
||||
|
|
|
|||
|
|
@ -178,6 +178,14 @@ class FileUpload extends FormWidgetBase
|
|||
$this->addJs('js/fileupload.js', 'core');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSaveData($value)
|
||||
{
|
||||
return FormWidgetBase::NO_SAVE_DATA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the current request to see if it is a postback containing a file upload
|
||||
* for this particular widget.
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use Backend\Classes\FormField;
|
|||
use Backend\Classes\WidgetBase;
|
||||
use Backend\Classes\WidgetManager;
|
||||
use System\Classes\ApplicationException;
|
||||
use Backend\Classes\FormWidgetBase;
|
||||
|
||||
/**
|
||||
* Form Widget
|
||||
|
|
@ -718,6 +719,8 @@ class Form extends WidgetBase
|
|||
: null;
|
||||
|
||||
$data[$field] = $widget->getSaveData($widgetValue);
|
||||
if ($data[$field] === FormWidgetBase::NO_SAVE_DATA)
|
||||
unset($data[$field]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue