Support the ongoing development of Laravel.io →
Requests Database Views
Last updated 1 year ago.
0

Not positive I understand you but I'm thinking you have so many fields when you edit form it doesn't fit the page can you do this in stages for example edit a, edit b, etc. Literally make three forms if you have to. Once a is complete have b load. A little hacky but I know of no other way. Again sorry if I misunderstood the question.
Is there a big problem with a user simply scrolling down to enter more fields?

0

Can you just post an array of fields containing the ID of the records that are complete?

0

you can check if the user submitted the form by Request::isMethod('post') .. on the same controller

if (Request::isMethod('post') {
   // process form data
} 
Last updated 8 years ago.
0

I'm sorry, I think I'm getting some confusion. Please forgive me. I think one thing I left out of the question was the fact that there is no direct input from the user. It's essentially a review page where they look at the items, but it's nothing more than a table of items from the database with no input fields. I just want to add something like an "accept" button where then it flags everything in the query (everything that is on the page). I hope I'm being descriptive enough, and I realize this is not a typical use case, and it may not even be something that is not possible.

I have the button and the post request working, but I just don't know how to grab the current query on the page and pass it to the post request to flag the items with no inputs.

0

Add another field to that same table and then once they accept it have it be a 0 for example or if they don't accept be a one kind of like a check box. Or vice versa a one would be accepted the 0 not accepted.

Last updated 8 years ago.
0

Yeah that's fine and all, and I could do that, but that still doesn't answer the original question, and I apologize for making it difficult to understand. What I'm wondering, is how would I know what to update? I'll give my use case here.

I'm grabbing the data pulled in with url variables like so:

Route::get('/update/{account}/{name}', 'SomeController@show');

So in the controller I have something like:

public function show($account, $update)
{
    $query = DB::table('updates')
        ->where('update', $update)
        ->where('account', $account);

    // return view
}

I get my list of stuff and I want to to have to accept them but clicking said button. So I create my POST route:

Route::post('/update/{account}/{name}/submit', ['as' => 'submit', 'uses' => 'SomeController@submit']);

And I do this because I don't know of any other way to submit against the data I have in the review (there are hundreds of thousands of records, and I'm showing, maybe a couple of hundred per user or so)

Then in my controller I do something like this:

public function submit($account, $update)
{
    DB::table('cic_updates')
        ->where('update', $update)
        ->where('account', $account)
        ->update(['processed' => 'Y']);

    // return redirect
}

When I actually click the button for submit, I get this:

http://site.test/update/%7Baccount%7D/%7Bname%7D/submit

It's not giving me the url variables in the post request. I don't even know if that's possible, since I've never tried this before (again, I'm guessing it's a security issue). I just can't think of another way to do this with how I'm pulling the data.

Last updated 8 years ago.
0

Are you attempting to update everything on that page that was clicked on or just weather the user accepted or did not accept what they were viewing, sorry still confused. If this is the case have two buttons to click, one button for accept another button for not accept. Maybe some screenshots of exactly what you're trying to do might help can't hurt.

0

The buttons aren't the issue. It's the post request when clicking the button using url variables, and I want to update all rows in the database that are shown to the user. Usually I would just use the id, but that's not an option in this particular case.

I'm basically using a 'where' query (shown above) that gives me results, and I want to update those same results (with the accept button click). Since I have no id's available to know what the update, I figure I'll update everything based on the original 'where' query, but I have no idea how to do that in the post request without id's or inputs. If I could somehow pass the query in the post request, that would work.

0

If I understand correctly, it looks like you are having hard time picking up the right candidate key to update. Where clause in this case will not be enough, it's actually not accurate enough as well.

Have you try storing your id like this? (Note: a not so-practical way tho, might consider encrypting these ids)

<input type="hidden" name="foo[]" value="foo1" >
<input type="hidden" name="foo[]" value="foo2" >
<input type="hidden" name="foo[]" value="foo3" >
etc

Then just simply update set where in

Last updated 8 years ago.
0

Yelldon said:

Yeah that's fine and all, and I could do that, but that still doesn't answer the original question, and I apologize for making it difficult to understand. What I'm wondering, is how would I know what to update? I'll give my use case here.

I'm grabbing the data pulled in with url variables like so:

Route::get('/update/{account}/{name}', 'SomeController@show');

So in the controller I have something like:

public function show($account, $update)
{
   $query = DB::table('updates')
       ->where('update', $update)
       ->where('account', $account);

   // return view
}

I get my list of stuff and I want to to have to accept them but clicking said button. So I create my POST route:

Route::post('/update/{account}/{name}/submit', ['as' => 'submit', 'uses' => 'SomeController@submit']);

And I do this because I don't know of any other way to submit against the data I have in the review (there are hundreds of thousands of records, and I'm showing, maybe a couple of hundred per user or so)

Then in my controller I do something like this:

public function submit($account, $update)
{
   DB::table('cic_updates')
       ->where('update', $update)
       ->where('account', $account)
       ->update(['processed' => 'Y']);

   // return redirect
}

When I actually click the button for submit, I get this:

http://site.test/update/%7Baccount%7D/%7Bname%7D/submit

It's not giving me the url variables in the post request. I don't even know if that's possible, since I've never tried this before (again, I'm guessing it's a security issue). I just can't think of another way to do this with how I'm pulling the data.

Can you post your code for opening the form and also your submit button

0

@awsp

That was my first solution. The problem I ran into was that the data may possibly be paginated, so I wouldn't have access to all of the hidden fields in the submit. Unless there is possibly a way around that as well? I'm open to suggestions.

@elite123

Absolutely. I'm using the form builder, at least for the for open:

{!! Form::open(['method' => 'POST', 'action' => 'SomeController@submit']) !!}

And the button:

<button type="submit" class="btn btn-success">
    <span class="glyphicon glyphicon-upload"></span> Submit Changes
</button>

It also doesn't work with the form builder button either (I had that first, but wanted to add an icon to the button.

0

You need to pass the $account and $name to your Form::open - this is from the 4.2 docs:

Form::open(array('action' => array('Controller@method', $user->id)))

http://laravel.com/docs/4.2/html#opening-a-form

0

OMG, Thank you elite123. I had never done this before and that worked like a charm! I very much appreciate you looking at this.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Yelldon yelldon Joined 2 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.