Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I discovered Covert Fields while searching for a way to enter regex validated links. I don't know PHP but the regex validation example provided in a previous issue was quite easy to follow. After the input passes validation, how could it be displayed as a clickable link? (I guess that support for the Link CCK field would be harder to implement...) Thank you.
Comments
Comment #1
john.karahalis CreditAttribution: john.karahalis commentedThanks for the interest, skizzo. I'm glad to see you learned some PHP by adding regex validation---PHP is a great language to know if you're going to be working with Drupal. Congratulations!
To display your field as a link, you can edit the field settings (Administer > Content Types > Manage Fields) and combine the HTML a tag with a little PHP for the "Code for Displayed Value".
For example, the following could be used to display a link to example.com with your stored value as the text for the link.
Hope that helps. Let us know if you get it working.
Comment #2
skizzo CreditAttribution: skizzo commentedThank you for helping me out! And yes, I got it working... but I guess I do not fully understand
stored/displayed values. Here is my textfield setting (filtered HTML input format being enabled):
At first run it works nicely. Problem is that whenever the node is saved again the displayed value
acts as a new entered value, recursively being appended to the original value. Would it make sense
for Covert Fields to load the stored value (rather than the displayed value) in form editing?
Comment #3
john.karahalis CreditAttribution: john.karahalis commentedOne approach would be to use something like the following, which would only customize the display on pages that are not the edit page.
Comment #4
kiwad CreditAttribution: kiwad commentedjohn.karahalis' workaround sounds a good idea and could maybe extended. in my case i'm using it with a user reference. User enters an email address and, if it is a valid user the stored value is UID, so I'll would do a something like that in my Code for Displayed Value :