The url of "Your cookie policy" is mandatory absolute, I would like to have the possibility to use a relative URL.
I have tried changing "url" to "path" into the dev version of the module:
$form['cookie_policy'] = [
'#type' => 'url',
'#title' => $this->t('Your cookie policy'),
'#description' => $this->t('If you already have a cookie policy, link to it here.'),
'#maxlength' => 255,
'#size' => 64,
'#default_value' => $config->get('cookie_policy'),
];
To
$form['cookie_policy'] = [
'#type' => 'url',
'#title' => $this->t('Your cookie policy'),
'#description' => $this->t('If you already have a cookie policy, link to it here.'),
'#maxlength' => 255,
'#size' => 64,
'#default_value' => $config->get('cookie_policy'),
];
But I get an error that said:
"This path does not exist or you do not have permission to link to"
And it is not possible any more link with an absolute URL.
Has someone any other idea?
Comments
Comment #2
dimr commentedComment #3
ckaotikNormally, you can enter a relative url in an
urlfield (which contains an uri string) by prefixing it, e.g.internal:/node/1. However, this is not yet handled by the module. To fix this properly, we'd have to convert the uri to a proper Url object using Url::fromUri() and set this for the relevant variables. Twig can handle url objects nicely and automatically callstoStringduring render. The JS however needs the plain text url. Probably something along the lines of this:As a workaround for now, you can change the
#typeof thecookie_policytotextfield, as that value is directly passed along to the template.Comment #4
hewok commentedHi,
you can override the module method with:
Comment #5
matt bThis needs to be fixed in the module, not with a workaround.
Comment #6
nitebreedClosing this because of the patch committed in #2910802: Update the policy link field type to a node entity autocomplete. I feel that functionality is more suited.