GithubHelp home page GithubHelp logo

Comments (6)

adamgoose avatar adamgoose commented on June 30, 2024

Sorry, but this isn't possible. Currently, and I do it frequently, one can use the same route name on two different HTTP methods. Thus, it's not possible to determine, with adequate certainty, which verb to use.

Close

Sent from my iPhone

On Sep 13, 2015, at 4:35 PM, Brett Taylor [email protected] wrote:

If I have the route:

Route::put('cart/add', ['as' => 'cart.add', 'uses' => 'CartController@addProduct']);
and in a view I have:

{!! Form::open(['route' => 'cart.add', 'class' => 'form-horizontal']) !!}
I expect the output:

But it does not create the _method hidden field. It should detect that the route is a PUT, and automatically output the _method hidden field.

Backwards compatibility shouldn't be an issue, as if people have named routes that aren't POST they're already creating their own _method field which will override the one Form::open would create.

Is this something that would be accepted as a pull request?


Reply to this email directly or view it on GitHub.

from html.

Glutnix avatar Glutnix commented on June 30, 2024

You use the same route name on two different methods: Are you sure you don't mean the URI fragments? It seems weird to have two named routes with the same name: what's the point?

from html.

adamgoose avatar adamgoose commented on June 30, 2024

Yes, I mean the same route name. I use the HTTP verb to differentiate. Whether you use this strategy or not, it's still impossible to ensure that it would resolve correctly.

Sent from my iPhone

On Sep 13, 2015, at 4:46 PM, Brett Taylor [email protected] wrote:

You use the same route name on two different methods: Are you sure you don't mean the URI fragments? It seems weird to have two named routes with the same name: what's the point?


Reply to this email directly or view it on GitHub.

from html.

Glutnix avatar Glutnix commented on June 30, 2024

Okay, thanks. Glad I asked before writing a PR :)

from html.

adamgoose avatar adamgoose commented on June 30, 2024

I appreciate the effort, though! Thanks for contributing. :)

from html.

Glutnix avatar Glutnix commented on June 30, 2024

Maybe I could clarify this in the documentation? Something along the lines of:

When using named routes be aware that Form::open will not inspect the route to determine the route's method. Be sure to specify the method yourself.

from html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.