Mr.Smith,please remove plugtry...

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.
Im having this error message everytime I try to submit the form:
The CSRF token is invalid. Please try to resubmit the form
My form code is this:
&form novalidate action="{{path('signup_index')}}" method="post" {{form_enctype(form)}} role="form" class="form-horizontal"&
&div class="form-group"&
{{ form_label(form.email, 'Email', {'label_attr': {'class': 'col-md-1 control-label'}}) }}
{{ form_widget(form.email, {'attr': {'class': 'col-md-2'}}) }}
{{ form_errors(form.email) }}
&div class="form-group"&
{{ form_label(form.nickname, 'Nickname', {'label_attr': {'class': 'col-md-1 control-label'}}) }}
{{ form_widget(form.nickname, {'attr':{'class': 'col-md-2'}}) }}
{{ form_errors(form.nickname, {'attr': {'class': 'col-md-3'}}) }}
&div class="form-group"&
{{ form_label(form.password, 'password', {'label_attr': {'class': 'col-md-1 control-label'}}) }}
{{ form_widget(form.password, {'attr': {'class': 'col-md-2'}}) }}
{{ form_errors(form.password, {'attr': {'class': 'col-md-3'}}) }}
&div class="form-group"&
{{ form_label(form.password_repeat, 'Repeat password', {'label_attr': {'class': 'col-md-1 control-label'}}) }}
{{ form_widget(form.password_repeat, {'attr':{'class': 'col-md-2'}}) }}
{{ form_errors(form.password_repeat, {'attr': {'class': 'col-md-3'}}) }}
&div class="form-group"&
&div class="col-md-1 control-label"&
&input type="submit" value="submit"&
32.2k72657
You need to add the _token in your form i.e
{{ form_row(form._token) }}
As of now your form is missing with the csrf token field,if you use the twig form functions to render your form like form(form) this will automatically renders the csrf token field for you but your code show your are rendering your form with raw html for form like &form&&/form& then you have to manually render the field
or simply add {{ form_rest(form) }} before closing tag of form
According to docs
This renders all fields that have not yet been rendered for the given
form. It's a good idea to always have this somewhere inside your form
as it'll render hidden fields for you and make any fields you forgot
to render more obvious (since it'll render the field for you).
32.2k72657
This happens because forms by default contain CSRF protection, which is not necessary in some cases.
You can disable this CSRF protection in your form class in getDefaultOptions method like this:
// Other methods omitted
public function getDefaultOptions(array $options)
return array(
'csrf_protection' =& false,
// Rest of options omitted
If you don't want to disable CSRF protection, then you need to render the CSRF protecion field in your form. It can be done by using {{ form_rest(form) }} in your view file, like this:
&form novalidate action="{{path('signup_index')}}" method="post" {{form_enctype(form)}} role="form" class="form-horizontal"&
&!-- Code omitted --&
&div class="form-group"&
&div class="col-md-1 control-label"&
&input type="submit" value="submit"&
{{ form_rest(form) }}
{{ form_rest(form) }} renders all fields which you haven't entered manually.
user3577953
Also you can see this error message, if your form has a lot of elements.
This option in php.ini cause of problem
; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 1000
Problem is that _token misses PUT (GET) request
So, you can increase value.
Also, it concerns a big files. Increasing the
upload_max_filesize
option will solve problem
Before your &/form& tag put:
{{ form_rest(form) }}
It will automatically insert other important (hidden) inputs.
2,30741744
In case you don't want to use form_row or form_rest and just want to access value of the _token in your twig template. Use the following:
&input type="hidden" name="form[_token]" value="{{ form._token.vars.value }}" /&
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled&&&&Hangover Cures
How To Get Over A Hang Over - Best Hangover RemediesUpdated on August 9, 2012
If you have a million piledrivers splitting your head,
have just enough energy to prise your eyelids open, and
a quick solution, skip the first part of my hub, with my apologies. After you are better, and resolve not to have a hangover again,
return to this point in my hub to find out how.First, let's see how you can avoid hangovers. 1. Eat before and during the drink session, not after. Some people I know drink on an empty tummy, dummies! That contributes to early nausea, headaches, not regulating the quantity of food, and funny pix of you posted over the net.And when you get sozzled silly, you might think it a good idea to skip
dinner and go straight to bed. Next time you do that, you deserve the ensuing hangover!2. Eat lots of fruit and salads.Alcohol in, vitamins out. So you need to compensate for those. So indulge in salads for sidesnacks, and drink glasses of orange and grape juice beforehand. I don't know if the juice in your vodka counts, sorry.3. Milk and Curds.I learnt this from a Brit friend. Before going out to wild parties, take in a lot of curds or milk. This gives an antinausea lining to your stomach walls.
Unless you want to be really wild!4. Know thyself. Stick to your drinking limits and you are safe. When I mix a beer session with rum or whisky, like I once did to oblige a stupid friend, I get a mega hangover the morning after. If something does not work for you, don't do it.5. Drink H2O.Many of my hangovers were due to my not drinking enough water. So pour in glasses of water, before and after session.6. Cut down on smoking.Sometimes the smoke is the culprit. More the cigarette count, the worse you feel later. If you don't smoke, choose a chair away from the smoke, or move your chair, if possible.It also makes sense not to sit in bar corners where the smoke remains longer. Central areas are better.7. Slow and Steady.Space out your drinks, or go slow. The fewer your drinks within a timeperiod, the less you are affected. Ah, yes, it kills the fun a bit, too. 8. Dance, talk, sing. Involve yourself in an
don't just sit there gulping down the drinks. You get less sozzled that way. Also cuts the danger of you dropping off to sleep, which is instant nausea when you wake up. And sing or dance only where you can. Though if you are bounced early enough, you won't have a big hangover, so singing and dancing is a good thing!9.
Get a good night's sleep.Sensible folks indulge only on Saturdays, and can sleep it off on Sunday. Less sleep could be the reason for your condition, friend, go back to sleep!
Throwing upMany folks have brought it to my kind attention that forcing yourself to throw up is a hangover cure. Friends, let me not stop you! Throw up if you want, but do it only if you already feel pukey. Pushing three fingers into throat and doing a toilet plunger act is not my idea of a hangover cure.If you feel like throwing up, don't try to stop it. Ideally, get out of bed to do so. Most people do it when they brush their teeth.After you have donated your exdrinks and snacks to the sink, you feel like a whole new person. Weak, but clean!
CuresOkay, okay, the top of your head comes off every time an ant passes by, and
this stupid guy is giving
you tips on how to avoid it next time? Stop swearing and listen:1. Drink lots of water or juice. (You could be dehydrated.)2. Drink soup.3. Eat something, specially fruits and salads. 4. Go back to sleep.5. Take a nice, hot, bath.6. Bite into a piece of ginger.7. Be nice to people. (Of course. Unwise to get into arguments now.)8. Have rice with curds. 9. Still there? Go back to sleep, do it now!
Useful hubs for hangover tips and cures
Recommended Hubs
(Kenny Wordsmith)
2by Jake Brannen
EDITOR'S CHOICE30by Kymberly Fergusson
EDITOR'S CHOICE21by Kitty
7by charlemont
14by Wanderlust
0by JohnMello
9by SarahLinny
0by Akhil Dev
Please rate this article using the scale below. The scale is from 1 to 10, where 10 is the best and 1 is the worst.
Copyright & 2015 HubPages Inc. and respective owners.Other product and company names shown may be trademarks of their respective owners.HubPages& is a registered Service Mark of HubPages, Inc.HubPages and Hubbers (authors) may earn revenue on this page based on affiliate relationships and advertisements with partners including Amazon, eBay, Google, and others.
(2.04 sec)

我要回帖

更多关于 please remove plug 的文章

 

随机推荐