Show/hide fields based on checkbox field value

Good morning,

I need to achieve this: In edit mode (create and update record), have checkbox field with this behavior:

  • if check == false --> show a text field and a dropdown field.
    In studio --> My module --> text field I set a default value (-1). When the fields are shown, the text field must populate with a value read from another table (custom table, into the same database, but not connected with module’s tables). I can’t set the default value into Studio cause the default value can be change depending on other process that write into my custom table from I would like to read the default value.
  • if check == true --> text field and dropdown field must hide, and (desirably) near che checkbox field show a label similar to "Default: <default value>" where is read from my custom table (or, I don’t know, a hint button that when is press or mouse over shows the informtions)


  1. how can I implement (upgrade safe and if is possibile best way) the logic to show/hide fields based on checkbox value ?
  2. It is possible read value from a custom table to populate the textfield? If true, how can I implement this mechanism?

I’ll try explain with a example:

  • In my custom table, I have one record with some columns in particular columnA and columnB; respectively with valueA and valueB values.
  • In my custom module, I have a checkbox field checkField, text field customA and dropdown field customB
  • when checkField == false, customA and customB fields, must show, and populate with values take from custom table: customA with valueA and customB with valueB.
  • when checkField == true, customA and customB fields, must hide, and customA set to “-1” (value defined into Studio), and if possibile, show valueA and valueB near checkbox field into a label

Thank you so much for the help, Hope my explanation was clear,

I can’t give you detailed instructions, but the general idea would be to

  • put everything you need onto the Edit view using normal methods (Studio, view defs)

  • now inject some Javascript into your view to handle the state changes based on the chekbox (search for some injection tutorial online)

Thank you so much for the anwser,
and about read values from a custom table?


When you’re overriding the view, you are in PHP code, you can do anything. You can either get the value you need from the bean (if it is a custom field in that bean) or even use direct SQL to grab it from anywhere in the database).

to read fields from a custom table, I opted to made an ajax request to a custom script that make a query to my table, and returns an array saved into a global var in javascript:

my js file:

var myValuesFromDatabase = new Array();
$('#EditView_tabs').ready(function() {
	type: 'GET',                   
	url: `<path_of_script.php>`,  
                 myValuesFromDatabase = fdata;
	error: function(fdata) {  						


And then in my javascript functions, I use myValuesFromDatabase


1 Like