rick Posted August 16, 2018 Posted August 16, 2018 How do I place a button next to the URL text field on a form created from the API? I have the following code to create the text field to display on the form and it works as expected. This text field contains a URL. I want to place a button next to this field that will open the URL in another tab. $field = $this->wire('modules')->get("InputfieldText"); $field->attr('id+name', 'some_link'); $field->title = "Link"; $field->label="Some Link"; $field->columnWidth = 50; $field->value = $this->some_link; $wrapper->add($field); The result of what I want is this: [ some_link ] [ view ] where the view button opens the URL in a different tab. Can someone offer some insight?
bernhard Posted August 16, 2018 Posted August 16, 2018 why not learn from existing solution? ? https://modules.processwire.com/modules/inputfield-urlchecker/ 1
flydev Posted August 16, 2018 Posted August 16, 2018 3 hours ago, rick said: I want to place a button next to this field that will open the URL in another tab. You could add the link with jQuery. select your DOM (input: some_link) element append the link to the previous selected element: $('#some_link').append('<a href="#" id="view-link">view</a>') use the click event to open the url : $('#view-link').on('click', function(e) { window.open($('#some_link').val(), '_blank'); }); something like that... 3
rick Posted August 16, 2018 Author Posted August 16, 2018 Thanks to you both. @flydev that solution sounds better. @bernhard, I just tried the url checker module and it throws errors when building a form dynamically through the API. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now