Page 1 of 1
[SOLVED] Is it possible to auto-fill in a text field via page URL or via URL query?
Posted: Fri Feb 21, 2025 11:16 am
by supak111
Is it possible to auto-fill a text file on a page via visiting the URL directly and by adding a query to the URL?
Say by visiting account login page at:
site.com/index.php?route=account/login
Can I add a query to URL to fill in the email-address field?
I was thinking maybe changing the URL to something like this:
site.com/index.php?route=account/login?email=Auto-Fill-Email-Field@gmail
How can I make this work?
.
Re: Is it possible to auto-fill in a text field via page URL or via URL query?
Posted: Fri Feb 21, 2025 4:25 pm
by nonnedelectari
supak111 wrote: ↑Fri Feb 21, 2025 11:16 am
Is it possible to auto-fill a text file on a page via visiting the URL directly and by adding a query to the URL?
Say by visiting account login page at:
site.com/index.php?route=account/login
Can I add a query to URL to fill in the email-address field?
I was thinking maybe changing the URL to something like this:
site.com/index.php?route=account/login?email=Auto-Fill-Email-Field@gmail
How can I make this work?
.
That would then be:
site.com/index.php?route=account/login&email=Auto-Fill-Email-Field@gmail
Re: Is it possible to auto-fill in a text field via page URL or via URL query?
Posted: Fri Feb 21, 2025 8:35 pm
by paulfeakins
supak111 wrote: ↑Fri Feb 21, 2025 11:16 am
Is it possible to auto-fill a text file on a page via visiting the URL directly and by adding a query to the URL?
Yes.
supak111 wrote: ↑Fri Feb 21, 2025 11:16 am
How can I make this work?
You need some code on the page that detects if those URL variables are set and then sets the value attribute of the inputs to it.
Re: Is it possible to auto-fill in a text field via page URL or via URL query?
Posted: Sat Feb 22, 2025 1:47 am
by supak111
Ok thanks guys, got it to work ツ
In theme view change:
Code: Select all
<input type="text" name="email" value="" required="required" id="emailField" class="form-control" />
TO:
Code: Select all
<input type="text" name="email" value="{{ email|e }}" required="required" id="emailField" class="form-control" />
In the controller file add this to in "public function index() {"
Code: Select all
// Check if 'email' exists in the GET request
$email = isset($this->request->get['email']) ? $this->request->get['email'] : '';
// Pass to the Twig template
$data['email'] = $email;