Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why we required form pointed to correct url? #1713

Closed
nowackipawel opened this issue Feb 10, 2019 · 1 comment
Closed

Why we required form pointed to correct url? #1713

nowackipawel opened this issue Feb 10, 2019 · 1 comment

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Feb 10, 2019

function form_open(string $action = '', $attributes = [], array $hidden = []): string
	{
		// If no action is provided then set to the current url
		if (! $action)
		{
			$action = current_url(true);
		} // If an action is not a full URL then turn it into one
		elseif (strpos($action, '://') === false)
		{
			$action = site_url($action);
		}

I've got many use cases (with javascript) where I don't want to define action as an URL. Is it necessary to force make action attribute as URL ? I want to make my form works only when JS is enabled.
I'd like to propose sth like that:

function form_open(string $action = '', $attributes = [], array $hidden = []): string
	{
		// If no action is provided then set to the current url
		if (! $action)
		{
			$action = current_url(true);
		} // If an action is not a full URL then turn it into one
elseif (strpos($action, '#') !== 0 && strpos($action, '://') === false)
		{
			$action = site_url($action);
		}

which allows strings begins from '#' to be a correct action for forms attribute

@lonnieezell
Copy link
Member

You've submitted a PR for this which I'll accept once you make the requested changes. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants