reference between a (module) class and a custom table

ruben verschueren asked on September 11, 2018 15:27

I'm adding fields to a class in a custom module. I want to reference a custom table I created, but I can only find how to it for another class.

Should I use the datasource and add a SQL query? The form control dropdown has ***Selector options. Should I see a selector for my custom table there?

I've created localizations for both the class and the custom table and assigned them both to the correct site.

I'm probably missing something, but can't seem to find the correct answer in the documentation.

Correct Answer

David te Kloese answered on September 24, 2018 16:10

think the format for display and value should be {%Name%} including the curly brackets

0 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on September 11, 2018 15:46

By default the control isn't available in your custom classes.

You could update the existing control (but can be overwritten easily when upgrading or importing data).

  • Go to the form controls module
  • search for the custom table selector (or table item if you want just 1 row)
  • scroll to the scope
    • select system tables (which includes your custom classes)

Image Text

If this suits your needs you might be thinking about just cloning your own copy the form control so you're safe for upgrades and imports overwriting the default Kentico control.

2 votesVote for this answer Mark as a Correct answer

ruben verschueren answered on September 11, 2018 15:50

Ah I knew there would be a clean way to do this. Thanks, I'll give that a try.

1 votesVote for this answer Mark as a Correct answer

ruben verschueren answered on September 24, 2018 15:04 (last edited on September 24, 2018 15:07)

A small follow up question. I've tested this out with the standard 'custom table Item selector' and 'custom table selector'. I also checked the 'integer number' datatype as I would rather save the key in my custom table field.

However when I open the user interface for my custom class, I get a disabled dropdownlist. here are my settings: Image Text

Image Text

Image Text

0 votesVote for this answer Mark as a Correct answer

ruben verschueren answered on September 25, 2018 11:19 (last edited on September 25, 2018 11:22)

That worked for the display name. the "name of the value" column is just the name itself, no quotes, percentage signs or curly braces needed... I found that in the event log.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on September 25, 2018 11:22

Is the custom table and your module assigned to the current site?

0 votesVote for this answer Mark as a Correct answer

ruben verschueren answered on September 25, 2018 11:23

@David, you're fast. I already updated my last answer. I found the solution. thank you for the assistance.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.