Skip to content

"Blank" visibility options that work for fieldset are missing from field config #1953

@Toutouwai

Description

@Toutouwai

Short description of the issue

In earlier versions of PW the full range of options were available for the Visibility > Presentation setting for FieldtypeFieldsetOpen fields.

The screenshot below is from PW 3.0.118

2024-07-25_194500

At some point many of these options were removed from InputfieldWrapper, which InputfieldFieldsetOpen extends.

2024-07-25_194654

But the four options relating to blank/populated are useful and they seem to work fine with FieldtypeFieldsetOpen. If I restore those options with the hook below...

$wire->addHookAfter('InputfieldFieldsetOpen::getConfigInputfields', function(HookEvent $event) {
	$inputfield = $event->object;
	$wrapper = $event->return;
	// Not for InputfieldFieldsetTabOpen
	if($inputfield instanceof InputfieldFieldsetTabOpen) return;
	$f = $wrapper->getChildByName('collapsed');
	if(!$f) return;

	// Add back the blank/populated options that were removed by InputfieldWrapper::getConfigInputfields
	$f->addOption(Inputfield::collapsedBlank, $this->_('Open when populated + Closed when blank'));
	if($inputfield->hasFieldtype !== false) {
		$f->addOption(Inputfield::collapsedBlankAjax, $this->_('Open when populated + Closed when blank + Load only when opened (AJAX)') . "");
	}
	$f->addOption(Inputfield::collapsedBlankLocked, $this->_('Open when populated + Closed when blank + Locked (not editable)'));
	$f->addOption(Inputfield::collapsedPopulated, $this->_('Open when blank + Closed when populated'));
});

...then the fieldset can be automatically collapsed or not based on whether the child fields are populated.

Seeing as this works, was the removal for FieldtypeFieldsetOpen unintended? Can support for these visibility settings be added back please?

Setup/Environment

  • ProcessWire version: 3.0.240

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions