From 6099f8252d5e9ffcfb038b226924dc03a097d476 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Fri, 12 Apr 2019 23:05:51 +0200 Subject: [PATCH 1/3] Check if field in database exists before adding to querybuilder. Fixes #46 --- src/Model/Multilingual.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Model/Multilingual.php b/src/Model/Multilingual.php index a612685..13a88db 100644 --- a/src/Model/Multilingual.php +++ b/src/Model/Multilingual.php @@ -11,6 +11,7 @@ namespace Terminal42\DcMultilingualBundle\Model; +use Contao\Database; use Doctrine\DBAL\Query\QueryBuilder; use Terminal42\DcMultilingualBundle\QueryBuilder\MultilingualQueryBuilderFactoryInterface; @@ -273,9 +274,10 @@ protected static function getMultilingualQueryBuilder() */ protected static function getRegularFields() { - $extractor = \DcaExtractor::getInstance(static::getTable()); + $extractor = \DcaExtractor::getInstance(static::getTable()); + $tableColumns = Database::getInstance()->getFieldNames(static::getTable()); - return array_keys($extractor->getFields()); + return array_intersect($tableColumns, array_keys($extractor->getFields())); } /** @@ -287,10 +289,11 @@ protected static function getTranslatableFields() { static::ensureDataContainerIsLoaded(); - $fields = []; + $fields = []; + $tableColumns = Database::getInstance()->getFieldNames(static::getTable()); foreach ($GLOBALS['TL_DCA'][static::getTable()]['fields'] as $field => $data) { - if (!isset($data['eval']['translatableFor'])) { + if (!isset($data['eval']['translatableFor']) || !in_array($field, $tableColumns, true)) { continue; } From d79bd6c4b375ab55cc9a1492e59be0d8c4d4b945 Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Fri, 12 Apr 2019 23:11:39 +0200 Subject: [PATCH 2/3] Fix focus input. Fixes #48 --- src/Driver.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Driver.php b/src/Driver.php index dfa88b2..24aaf4d 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -395,13 +395,18 @@ public function edit($intId=null, $ajaxId=null) - +'; + // Set the focus if there is an error + if ($this->noReload) + { + $return .= ' '; + } // Begin the form (-> DO NOT CHANGE THIS ORDER -> this way the onsubmit attribute of the form can be changed by a field) $return = $version . ' From 99aa5de97f6d697850d5462bd981ccc109e9b5dc Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Fri, 12 Apr 2019 23:15:30 +0200 Subject: [PATCH 3/3] Add novalidate to fix deletion of languages. Fixes #49 --- src/Driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Driver.php b/src/Driver.php index 24aaf4d..b070b48 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -414,7 +414,7 @@ public function edit($intId=null, $ajaxId=null) '.$GLOBALS['TL_LANG']['MSC']['backBT'].'') . ' '.\Message::generate().' -
onsubmit) ? ' onsubmit="'.implode(' ', $this->onsubmit).'"' : '').'> +onsubmit) ? ' onsubmit="'.implode(' ', $this->onsubmit).'"' : '').' novalidate>