Feature Request: Field Editor List Options - advance mysql query

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

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

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

By TimHurd - July 18 - edited: July 18

Hi Jeff,

I am new to CMS Builder but I thought I could pitch in with an answer. Dave's solution will work, but is missing a few more details. 

On the textarea element with the name "optionsQuery" a few lines up from the "Available vars" line, add two additional attributes. One is

id="optionsQuery"

and another is...

style="height: 300px;"

So in the end your textarea element should look like the following...

<textarea name="optionsQuery" id="optionsQuery" cols="60" rows="3" style="height: 300px;" class="form-control text-nowrap setAttr-spellcheck-false textareaGrow" data-growsize="10"><?php echo htmlencode($field['optionsQuery']) ?></textarea>

I believe after this change, the JavaScript Dave gave you should turn that box into an editor box with line numbers. Attached is a screenshot.

Now of course I don't know if it is safe to edit these files and if they will be overwritten by future updates, but at least it can get that working for now and perhaps Dave's team can then put it in as part of core.

I hope this is what you were looking to do. :)

Tim Hurd
Senior Application Developer
TimHurd.com
Attachments:

mysql-options-editor.png 26K