1

I'm editing an entry via an entry form as documented here: https://docs.craftcms.com/v3/dev/examples/entry-form.html

How would I be able to save a link field that's using https://github.com/sebastian-lenz/craft-linkfield ?

I tried this:

<input id="website" type="text" name="fields[website]">

(where "website" is the handle of the link field) but that just throws a syntax error (in json_decode) at vendor/sebastianlenz/linkfield/src/fields/LinkField.php:112

It works fine for other elements that use one of the built-in field types.

Is this even possible using the standard entries/save-entry endpoint? Or would I need to write a custom controller, and how so?

1

Found a solution by inspecting the HTML for the entry edit form in the CP. This works:

<input id="fields-website-type" name="fields[website][type]" value="url" type="hidden">
<input id="fields-website-isCpFormData" name="fields[website][isCpFormData]" value="true" type="hidden">
<input id="website" type="text" name="fields[website][url]">
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.