Skip to content

Commit

Permalink
see cl 0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Patzer committed Jul 16, 2018
1 parent 6576af3 commit 3a4ea7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.3.4] - 2018-07-16

#### Fixed
- missing ajax action check in HookListener::executePostActionsHook()

## [0.3.3] - 2018-07-16

#### Fixed
Expand Down
50 changes: 26 additions & 24 deletions src/EventListener/HookListener.php
Expand Up @@ -85,39 +85,41 @@ public function initializeSystemHook()
*/
public function executePostActionsHook($action, DataContainer $dc)
{
if ($this->framework->getAdapter(Input::class)->post('field')) {
$this->framework->getAdapter(Controller::class)->loadDataContainer($dc->table);
if (DcaHandler::FieldpaletteRefreshAction === $action) {
if ($this->framework->getAdapter(Input::class)->post('field')) {
$this->framework->getAdapter(Controller::class)->loadDataContainer($dc->table);

$name = $this->framework->getAdapter(Input::class)->post('field');
$field = $GLOBALS['TL_DCA'][$dc->table]['fields'][$name];
$name = $this->framework->getAdapter(Input::class)->post('field');
$field = $GLOBALS['TL_DCA'][$dc->table]['fields'][$name];

// Die if the field does not exist
if (!is_array($field)) {
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
// Die if the field does not exist
if (!is_array($field)) {
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}

/** @var Widget $class */
$class = $GLOBALS['BE_FFL'][$field['inputType']];
/** @var Widget $class */
$class = $GLOBALS['BE_FFL'][$field['inputType']];

// Die if the class is not defined or inputType is not fieldpalette
if ('fieldpalette' !== $field['inputType'] || !class_exists($class)) {
return;
}
// Die if the class is not defined or inputType is not fieldpalette
if ('fieldpalette' !== $field['inputType'] || !class_exists($class)) {
return;
}

$attributes = $this->framework->getAdapter(Widget::class)->getAttributesFromDca($field, $name, $dc->activeRecord->{$name}, $name, $dc->table, $dc);
$attributes = $this->framework->getAdapter(Widget::class)->getAttributesFromDca($field, $name, $dc->activeRecord->{$name}, $name, $dc->table, $dc);

/** @var Widget $widget */
$widget = new $class($attributes);
$widget->currentRecord = $dc->id;
/** @var Widget $widget */
$widget = new $class($attributes);
$widget->currentRecord = $dc->id;

$data = ['field' => $name, 'target' => '#ctrl_'.$name, 'content' => $widget->generate()];
$data = ['field' => $name, 'target' => '#ctrl_'.$name, 'content' => $widget->generate()];

if ($widget->submitOnChange) {
$data['autoSubmit'] = $dc->table;
}
if ($widget->submitOnChange) {
$data['autoSubmit'] = $dc->table;
}

die(json_encode($data));
die(json_encode($data));
}
}
}

Expand Down

0 comments on commit 3a4ea7a

Please sign in to comment.