Problem/Motivation

The current validation of the iFrame config values does not allow to input a 100% width for the iFrame display:

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    if ($form_state->getValue('width') <= 0) {
      $form_state->setError($form['width'], $this->t('Width must be greater than 0.'));
    }
    if ($form_state->getValue('height') <= 0) {
      $form_state->setError($form['height'], $this->t('Height must be greater than 0.'));
    }
  }

Modules that provide default browser do set this to 100%, for instance the file_browser's one:

display_configuration:
  widget_ids:
    735d146c-a4b2-4327-a057-d109e0905e05: 'Upload files'
    a4ad947c-9669-497c-9988-24351955a02f: 'Files listing'
  width: 100%
  height: 768
  link_text: 'Select files'
  auto_open: true

This implies that a site builder cannot modify this browser trough the UI using the configuration form.

Proposed resolution

Improve the validation of this display plugin to allow the width of the iFrame display to be used either in px or in %.

Comments

marcoscano created an issue. See original summary.

marcoscano’s picture

Status: Active » Needs review
StatusFileSize
new2.7 KB

The patch attached improves the validation to allow %.

If this patch ends up being committed, please give authorship to jonhattan, who whispered me the regex pattern :)

sokru’s picture

Status: Needs review » Reviewed & tested by the community

Tested, works as advertised.

slashrsm’s picture

StatusFileSize
new2.83 KB
new600 bytes

Added description to the form element.

slashrsm’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

  • slashrsm committed e2f153c on 8.x-1.x authored by marcoscano
    Issue #2766099 by slashrsm, marcoscano, sokru: Allow iFrame displays...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.