Open corneliusio opened 2 days ago
Should be fixed for the next release. To get this early, run composer require verbb/hyper:"dev-craft-5 as 2.2.1"
.
@engram-design Fantastic! That's fixed the issues for sure. I am a bit curious about this part:
The link value input of the custom Hyper "Dropdown" link type will automatically populate with a serialized array of ids that appear to correspond to the element ids of it's child hyper field. I originally expected I'd need to add an event handler before save or validation to populate this input with something like "#" just to allow the field to pass validation, but this never ended up being the case due to this behavior.
This is no longer occurring which makes sense to me, however when I go to implement the solution I'd mentioned it doesn't seem to work:
Event::on(
Entry::class,
Entry::EVENT_BEFORE_VALIDATE,
function (YiiModelEvent $event): void {
/** @var Entry $block */
$block = $event->sender;
if ($block->type->handle === 'dropdown') {
foreach ($block->menu as $menu_item) {
if ($menu_item->label === 'Dropdown') {
// none of the following appear to work. no matter how
// I try to programmatically populate this field,
// I get a `Link cannot be blank.` validation error.
$menu_item->setAttributes([ 'linkValue' => '#' ], false);
$menu_item->setAttribute('linkValue', '#');
$menu_item->linkValue = '#';
}
}
}
},
);
Is there any way to bypass the validation for the link if needed? I know I'm stretching the functionality here a bit but I'd thought I'd gotten away with one since it was working for quite some time.
Also, while messing with this I came across another issue. The following line references an undefined variable $item
which I'm assuming should be $value
:
https://github.com/verbb/hyper/blob/craft-5/src/models/LinkCollection.php#L134
Describe the bug
We've suddenly started having an issue where nested hyper fields are not updating.
Steps to reproduce
We currently have the following structure for a set of fields to allow for a site's main navigation:
To break it down fully, we have a matrix field with two types, "Dropdown" and "Menu Item". The "Dropdown" matrix type has a plain text field for the dropdown label in the menu and a Hyper field that can be populated with standard link types as well as a custom one that allows for an additional layer of navigation links. This custom link type uses the default "Link Text" input for it's label and has a different hyper field that populates this dropdown (this hyper field does not have an additional "dropdown" type so the nesting stops here).
Now there are a couple things happening here that are odd:
Craft CMS version
5.5.3
Plugin version
2.2.1
Multi-site?
No
Additional context
I'm more than happy to pass along project config files if it would help.