Support

Account

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.
    };
    }`