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

[NFR] Form::setAction behaving as a shortuct for Phalcon\Mvc\Url component #13523

Closed
scrnjakovic opened this issue Oct 13, 2018 · 2 comments
Closed
Labels
stale Stale issue - automatically closed

Comments

@scrnjakovic
Copy link
Contributor

scrnjakovic commented Oct 13, 2018

I remembered using this with various parts of the framework that it felt natural and intuitive to use it with Form::setAction as well, but turns out you can't. I don't see any reason why Form::setAction wouldn't act as a shortcut for Phalcon\Mvc\Url so we can do something like:

$form->setAction(
    [
        'for' => 'my-named-route'
    ]
);

In case we agree on this one, I propose to consider implementing it using variadic function and argument unpacking/splat operator instead of call_user_func_array, if it is supported in Zephir ofc. Maybe we should do some benchmarking first?

public function setAction(...$args)
{
    $argsCount = count($args);

    if ($argsCount == 1 && is_string($args[0])) {
        $this->action = $args[0];
        return $this;
    }

    if ($argsCount > 0) {
        $this->action = $this->url->get(...$args);
        return $this;
    }

    throw new \InvalidArgumentException('Form::setAction requires at least one argument');
}
@scrnjakovic
Copy link
Contributor Author

/cc @niden @Jurigag @sergeyklay ?

@stale
Copy link

stale bot commented Jan 21, 2019

Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues

@stale stale bot added the stale Stale issue - automatically closed label Jan 21, 2019
@stale stale bot closed this as completed Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issue - automatically closed
Projects
None yet
Development

No branches or pull requests

1 participant