mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
More strict checking of addItem request for child repeaters (#4814)
Similarly named repeater fields being used in viewBag variables were being assigned aliases which succeeded the `strpos` check on line 407. This will more clearly look for a child repeater form and index. Fixes #4808
This commit is contained in:
parent
5839b6869a
commit
c17cb58aa1
@ -98,7 +98,7 @@ class Repeater extends FormWidgetBase
|
||||
public function init()
|
||||
{
|
||||
$this->prompt = Lang::get('backend::lang.repeater.add_new_item');
|
||||
|
||||
|
||||
$this->fillFromConfig([
|
||||
'form',
|
||||
'prompt',
|
||||
@ -404,15 +404,15 @@ class Repeater extends FormWidgetBase
|
||||
if ($this->alias === $widgetName) {
|
||||
// This repeater has made the AJAX request
|
||||
self::$onAddItemCalled = true;
|
||||
} else if (strpos($widgetName, $this->alias) === 0) {
|
||||
} else if (strpos($widgetName, $this->alias . 'Form') === 0) {
|
||||
// A child repeater has made the AJAX request
|
||||
|
||||
// Get index from AJAX handler
|
||||
$handlerSuffix = str_replace($this->alias . 'Form', '', $widgetName);
|
||||
preg_match('/^[0-9]+/', $handlerSuffix, $matches);
|
||||
|
||||
$this->childAddItemCalled = true;
|
||||
$this->childIndexCalled = (int) $matches[0];
|
||||
if (preg_match('/^[0-9]+/', $handlerSuffix, $matches)) {
|
||||
$this->childAddItemCalled = true;
|
||||
$this->childIndexCalled = (int) $matches[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user