Open
Description
I'm working on a migration script right now where I need to create linkfield values programmatically. The README is lacking instructions on how to set values programmatically (in PHP), which fields are supported, how to switch link types, etc. By trial and error as well as inspecting the HTML code for the field I found that this seems to work:
$entry->setFieldValue('my_typed_link_field', [
'type' => 'url',
'cpForm' => [
'url' => [
'linkedUrl' => 'https://example.com'
],
],
'customText' => 'Link text for example.com',
];
Is this the best way to set the value? Is there a simpler approach? Also, the nested array with cpForm
as a key is kind of ... awkward to use. Not sure if I'm doing it wrong.
Anyway, adding a section to the README that explains how to set values programmatically would be really helpful!