In some projects database configuration can be different then $connection['default']['database'] or there are could be different version of databases. This is the case for us and we face this warning:

Notice: Undefined index: database in Drupal\view_custom_table\Form\AddViewsCustomTable->buildForm() (line 106 of /var/www/html/web/modules/contrib/view_custom_table/src/Form/AddViewsCustomTable.php)
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

LOBsTerr created an issue. See original summary.

lobsterr’s picture

Assigned: lobsterr » Unassigned
Status: Active » Needs review

in some cases we can have multiple DB connections, in addition not all DB connections have 'database' key:

$databases['mysql']['default'] = array (
  'database' => getenv('DRUPAL_DATABASE_NAME'),
  'username' => getenv('DRUPAL_DATABASE_USERNAME'),
....

$databases['mysql']['replica'] = array (
  'database' => getenv('DRUPAL_DATABASE_NAME'),
  'username' => getenv('DRUPAL_DATABASE_USERNAME'),
....

  $databases['sparql_default']['default'] = [
    'prefix' => '',
    'host' => getenv('DRUPAL_SPARQL_HOSTNAME'),
    'port' => getenv('DRUPAL_SPARQL_PORT'),
    'namespace' => 'Drupal\\sparql_entity_storage\\Driver\\Database\\sparql',
    'driver' => 'sparql',
  ];

p.s. I fixed small misspells and improve a bit code style.

lobsterr’s picture

Title: Don't use hardcoded $connection['default']['database'] on view custom table » Don't use hardcoded $connection['default']['database'] on view custom table form

joseph.olstad made their first commit to this issue’s fork.

joseph.olstad’s picture

lobsterr’s picture

Status: Needs review » Reviewed & tested by the community

I have tested it. Looks ok for me!

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

in 2.0.x dev

joseph.olstad’s picture

Tagged and released 2.0.6 thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.