Skip to content

Why we required form pointed to correct url? #1713

Description

@nowackipawel
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions