Skip to content

Commit

Permalink
Tweak to list and element save, when creating new, make sure table do…
Browse files Browse the repository at this point in the history
…esn't end in _ or element doesn't start with _. That messes up the tablename___elementname handling whenever we split on ___, if there is an extra _ we don't know if it belongs on the end of table or start of field.
  • Loading branch information
cheesegrits committed Jul 5, 2017
1 parent 0dcfe68 commit a052bd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions administrator/components/com_fabrik/models/element.php
Expand Up @@ -507,6 +507,9 @@ public function save($data)

if ($new)
{
// Can't have elements starting with _
$name = ltrim($name, '_');
$data['name'] = $name;
// Have to forcefully set group id otherwise list model id is blank
$elementModel->getElement()->group_id = $data['group_id'];
}
Expand Down
7 changes: 5 additions & 2 deletions administrator/components/com_fabrik/models/list.php
Expand Up @@ -14,8 +14,8 @@

require_once 'fabmodeladmin.php';

use \Joomla\Utilities\ArrayHelper;
use \Joomla\Registry\Registry;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

/**
* Fabrik Admin List Model
Expand Down Expand Up @@ -696,6 +696,9 @@ public function save($data)
// Mysql will force db table names to lower case even if you set the db name to upper case - so use clean()
$newTable = FabrikString::clean($newTable);

// can't have table names ending in _
$newTable = rtrim($newTable, '_');

// Check the entered database table doesn't already exist
if ($newTable != '' && $this->databaseTableExists($newTable))
{
Expand Down

0 comments on commit a052bd3

Please sign in to comment.