Open bob-pixeldeluxe opened 3 months ago
You can't hide the linkValue
field, that's the one required field you need to include. Whilst you can create a "custom" link type in this fashion, I'd recommend a proper element link type.
A quick example of this:
namespace modules\sitemodule;
use craft\events\RegisterComponentTypesEvent;
use modules\sitemodule\FormieLink;
use verbb\hyper\services\Links;
use yii\base\Event;
Event::on(Links::class, Links::EVENT_REGISTER_LINK_TYPES, function(RegisterComponentTypesEvent $event) {
$event->types[] = FormieLink::class;
});
<?php
namespace modules\sitemodule;
use Craft;
use verbb\formie\elements\Form;
use verbb\hyper\base\ElementLink;
use verbb\hyper\fieldlayoutelements\LinkField;
use verbb\hyper\fields\HyperField;
class FormieLink extends ElementLink
{
public static function elementType(): string
{
return Form::class;
}
public static function checkElementUri(): bool
{
return false;
}
public function getSettingsHtml(): ?string
{
$variables = $this->getSettingsHtmlVariables();
return Craft::$app->getView()->renderTemplate("hyper/links/_element/settings", $variables);
}
public function getInputHtml(LinkField $layoutField, HyperField $field): ?string
{
$variables = $this->getInputHtmlVariables($layoutField, $field);
return Craft::$app->getView()->renderTemplate("hyper/links/_element/input", $variables);
}
}
That way, the linkValue
field becomes an element select field for a Formie Form.
Describe the bug
Im adding a custom link type for a formie form now I want to hide the link value field. It wil be a form popup.
See the screenshot the checkbox right hidden is checked "verbergen" But now it shows this:
Looking with the inspector it does seem to be link value: name="fields[button][0][linkValue]"
Steps to reproduce
Craft CMS version
4.8.6
Plugin version
1.1.25
Multi-site?
Yes
Additional context
No response