In the "Read Only Mode" module's configuration page (/admin/config/development/maintenance),

Read Only Mode -> Allowed forms -> Forms that can be viewed

The description of the textarea (site_readonly_forms_viewonly) says:

These forms are allowed to be viewed but will not accept form submissions. Enter one form id per line. You may use the wildcard character '*' to use loose matches. For example: webform* will match all webforms. Note that the following forms will always be allowed: node_admin_content, comment_admin_overview.

But, if we enter the form id in that text area and then check the page having that form, we just see the warning message. All the form elements seems to be removed.

According the description, we should see all the form elements with submit event disabled.

function readonlymode_form_alter(&$form, $form_state, $form_id) {
  $mode = _readonlymode_form_check($form_id);
  if ($mode != READONLYMODE_FORM_ALLOWED) {
    // Check whether the form is a fresh form being served to the user.
    if (!isset($form_state['input']['form_token'])) {
      // If a redirect URL is set, then we redirect to it.
      if ($url = variable_get('site_readonly_url', '')) {
        drupal_goto($url);
      }
      else {
        // Replace FAPI #after_build handlers with our block form.
        $form['#after_build'] = array('readonlymode_block_form');
      }
    }
  }

  $path = current_path();
  if (user_access('readonlymode access forms') && variable_get('site_readonly', FALSE) && $path != 'admin/config/development/maintenance') {
    drupal_set_message(t('The site is currently set to read-only, content moderation is disabled for all users without the "Access all forms while in maintenance" permission. <a href="@link">Go online</a>.', array('@link' => url('admin/config/development/maintenance'))), 'warning', FALSE);
  }

  $form['#validate'][] = 'readonlymode_check_form_validate';
}

Seeing the codes, it looks like the constants READONLYMODE_FORM_DENIED and READONLYMODE_FORM_VIEWONLY are behaving the same. The result is also same if we remove the "Forms that can be viewed" option.

Comments

chrishks’s picture

Status: Needs work » Needs review
StatusFileSize
new1.05 KB

This patch adds a check for which constant is set, and adds the appropriate #after_build callback.

lanny heidbreder’s picture

StatusFileSize
new886 bytes

Patch in #1 works, once it's modified to apply correctly. Attached is a Drupal-standards reroll. Thanks, @chrishks!

lanny heidbreder’s picture

astonvictor’s picture

Status: Needs review » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.