Home › Forums › General Issues › Extend default ACF Link field › Reply To: Extend default ACF Link field
This seems to be the answer across multiple topic in acf forums ;(
Say we want to add an ID – its easy to attach a field
into the link dialog box. But the data isn’t being saved
with acf.
$('#link-options').append(
<div>
<div className=”flex flex-row”>
<label htmlFor=”wpse_link_class col-6″>
<span>Button Type</span>
<select name=”wpse-link-class” id=”wpse_link_class”>
<option value=”normal”>normal</option>
<option value=”btn btn-yellow”>Yellow button</option>
<option value=”btn btn-yellow btn-lg”>Yellow button (big)</option>
<option value=”btn btn-outline”>Outline button</option>
<option value=”btn btn-outline btn-lg”>Outline button (big)</option>
</select>
</label>
</div>
<label for=”sgx_custom_link_id”>
<span>Link ID</span>
<input type=”text” name=”sgx_custom_link_id” id=”sgx_custom_link_id” />
</label>
</div>
`);
wpLink.getAttrs = function() {
wpLink.correctURL();
return {
class: $( ‘#wpse_link_class’ ).val(),
href: $.trim( $( ‘#wp-link-url’ ).val() ),
target: $( ‘#wp-link-target’ ).prop( ‘checked’ ) ? ‘_blank’ : ”,
id: $( ‘#sgx_custom_link_id’ ).val() // this doesn’t work.
};
}`
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.