Feature Request: Field Editor List Options - advance mysql query

4 posts by 3 authors in: Forums > CMS Builder
Last Post: July 18, 2024   (RSS)

By kitsguru - July 11, 2024

Since the option for "get options for MySQL query" uses mysql statements, it would be great if this could be formatted for code with line numbers instead of a no-wrap text box.

USE Case

SELECT 0 as num, "" as title
UNION
SELECT num, title
  FROM `<?php echo $TABLE_PREFIX ?>locations`
WHERE use_company_lookup  = 1
Jeff Shields
yaadev.com

By Dave - July 12, 2024

Hi Jeff, 

Sure, here's a quick patch to add that.  We can add it to the next version as well.

  • Open /lib/menus/database/editField.php
  • Search for: Available vars
  • Add the code in the <script> tags below
echo t('Available vars: $ESCAPED_FILTER_VALUE, $CURRENT_USER, $RECORD');
?><br><br>

<script>
  document.addEventListener("DOMContentLoaded", function () {
      textareaToAceEditor('optionsQuery', 'mysql', false, 5, 25);
  });
</script>

Let me know if that works for you.  Thanks!

Dave Edis - Senior Developer
interactivetools.com

By kitsguru - July 17, 2024

Unfortunately, this didn't work. I have the following error in the concole.

Uncaught TypeError: Window.getComputedStyle: Argument 1 is not an object.
    textareaToAceEditor https://yaaws5.yaa.test/cmsb/lib/admin_functions.js?v=1720050496:585
    <anonymous> https://yaaws5.yaa.test/cmsb/admin.php?menu=database&action=editField&tableName=cmsb_bios&fieldname=locations&:681
Jeff Shields
yaadev.com