Giter VIP home page Giter VIP logo

Comments (6)

ermGit avatar ermGit commented on July 24, 2024 3

Interestingly enough, it is 3 years later and ACF still does not support Relative links.

from acf.

timichango avatar timichango commented on July 24, 2024 3

Interestingly enough, it is 3 years later and ACF still does not support Relative links.

Nor should it, if the goal of that specific field type is to provide link format validation (which it presumably is), per the HTML5 specification, which states that the URL property of an HTML5 input (ie. <input type="url"> should have "A single properly-formed absolute URL" as its entry, for the input to be valid. @elliotcondon indicated as much in his response above.

from acf.

elliotcondon avatar elliotcondon commented on July 24, 2024 1

Hi @lordspace

Thanks for the request.

The HTML5 'url' input does not currently allow for a non 'http' links (relative url).
https://stackoverflow.com/questions/3670437/input-type-url-for-relative-urls

For now, I suggest using a basic text input which won't have any built in browser validation.

from acf.

ermGit avatar ermGit commented on July 24, 2024

from acf.

timichango avatar timichango commented on July 24, 2024

From:  Eric Moore Why couldn't there be a toggle for which type you wanted the link to be?  ACF seems to feel strongly about the absolute type, so that type could be the default selection.

Respectfully, Eric, I suspect that you're missing the point of the URL field. As far as I can tell, it's there SPECIFICALLY for when you need a simple URL field input with strict input format validation. So changing that behaviour would inherently defeat its entire purpose.

If you want a field for relative links, then you implicitly don't care about URL format validation for your use-case, and thus you have multiple other options at your fingertips:

  1. Use a "link" field type (that field provides the dual option of typing your own link and selecting from site posts/pages, and does support relative links — I just tested it to double check)
  2. Use relationship field to establish your in-site linking, and then resolve the link url in your template (this is actually a lot more robust than storing relative link values manually, since it's based on post_id, so if you move the URL/path to the relational target post/page, the resolved links will automatically change to reflect the new path).
  3. Just use a plain text field (as @elliotcondon suggested three years ago)

Given the array of different ways to skin this cat: what's driving the fixation on having the URL field do something that it presumably wasn't designed to do?

from acf.

t-lock avatar t-lock commented on July 24, 2024

Probably could go ahead and mark this as closed.

from acf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.