Fixes #761 - Widgets can support proxy fields too

This commit is contained in:
Samuel Georges 2014-11-27 19:15:15 +11:00
parent 3dbe487698
commit 78c5a6af5d
1 changed files with 8 additions and 6 deletions

View File

@ -803,13 +803,15 @@ class Form extends WidgetBase
* Give widgets an opportunity to process the data. * Give widgets an opportunity to process the data.
*/ */
foreach ($this->formWidgets as $field => $widget) { foreach ($this->formWidgets as $field => $widget) {
$widgetValue = array_key_exists($field, $data) $parts = Str::evalHtmlArray($field);
? $data[$field] $dotted = implode('.', $parts);
: null;
$data[$field] = $widget->getSaveData($widgetValue); $widgetValue = $widget->getSaveData(array_get($data, $dotted));
if ($data[$field] === FormWidgetBase::NO_SAVE_DATA) { if ($widgetValue === FormWidgetBase::NO_SAVE_DATA) {
unset($data[$field]); array_forget($data, $dotted);
}
else {
array_set($data, $dotted, $widgetValue);
} }
} }