Menu

#2778 How to add an info-box with text (and a checkbox) above the save button for specific rooms only?

open
nobody
None
1
2023-07-04
2023-06-26
Thomas S.
No

Hi

My customer has the requirement that only for two rooms in an area, above the "save" button a text-box with informational text should be displayed ("by clicking "save" i confirm the rules and regulations")?
Can this be done and if so, how (maybe in a way that the textbox has some css that it looks like an informational message / blue)?

Even better (but also still don't know how to do it) would be if you have a checkbox next to the informational message you have to click so that you can click the "save" button (which should be greyed out otherwise).

Please help me fix this issue. This is really important for my customer.

Best,
Thomas

Discussion

  • Campbell Morrison

    Yes, it can be done. The simplest way to do it is to add some custom JavaScript in a custom .js file (see systemdefaults.inc.php) and then arrange for the text and checkbox to be added when those two rooms are selected and for the Save button to be disabled until the checkbox is checked.

     
  • Thomas S.

    Thomas S. - 2023-07-04

    Hi

    Can you please provide a very basic sample?

     
  • Campbell Morrison

    The shell will look something like this:

    $(document).on('page_ready', function() {
      $('form#main #rooms').on('change', function() {
          // Get the rooms that have been selected
          // If one of the rooms is one you care about then add the checkbox and text
          // and disable the Submit button until the checkbox is checked.
        }).trigger('change');
    });
    

    You'll need to fill in the gaps yourself with some jQuery.