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
Comment #2
marcoscanoThe 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 :)
Comment #3
sokru commentedTested, works as advertised.
Comment #4
slashrsm commentedAdded description to the form element.
Comment #5
slashrsm commentedCommitted.