MethodNotAllowedHttpException in submitting equation format from form textarea (ckeditor) - laravel

Hi there I am submitting a equation from ckeditor and geting MethodNotAllowedException though my form has method type post and route also post.
Here is my view.
<form class="form-horizontal" action="{{route('set-question')}}" id="submit_form" method="post">
{{csrf_field()}}
<div class="col-md126 col-md-9 col-md-offset-1">
<label class="control-label">Question</label>
<p class="help-block" style="font-size:12px;">Question is required</p>
<textarea name="question" class="ckeditor"></textarea>
<input type="submit" class="btn btn-success" value="Submit">
</div>
</form>
If I type this or some other equation only then other problem arise. I have saved by typing other format even with bengali language that was good. Bellow is my route and then the typography I was able to save in db via this route and view.
Route::post('add-question','Admins\ExamController#addQuestion')->name('set-question');
The successful tries.
But after the highlighted equation or format i got MethodNotAllowedHttpException.
Please suggest me what I'm missing.
Thank you in advance.

You can clean your cache. Because i faced sometime this type of problem and after clean my cache it will be fine.
One thing you can try with name route like: name('set.question)

Related

Laravel not rendering form element, but only the contents inside

I have been stumped on this for a couple hours and can not figure a way around it.
Larvel 8 with Livewire
I have a very basic form.
<form action="/dashboard/payment" method="POST">
#csrf
<button type="submit" class="btn btn-primary my-3 w-100" id="checkout-button">
<span wire:loading>Please Wait</span>
<span wire:loading.remove>Pay - $
<span>100</span>
<br>
<small>Description of payment</small>
</span>
</button>
</form>
But the form tag itself it is not rendering the html. It is only rendering the button inside.
When incrementing a value with another button, the form tag is then rendered into html and the button can be used as expected.
The incrementing button only ++ to a value and updates the database with the new value.
This is the only thing holding me back, I have searched everywhere but cant find any information about form tags not rendering.
Note: Neither the opening tag or the closing tag is rendered until the other button is pressed.
Any ideas or information would be fantastic and greatly appreciated.

save data from two forms to the database in laravel

How do save data into a database with a button that is located different from the input form?
this is my sample code
<form action="{{ route('store') }}">
#csrf
<input type="text" name="title"></form>
<form action="{{ route('store') }}">
#csrf
<button class="btn" type="submit">Submit</button></form>
when I run the code above, and output it via dd (...). it can't run. can the above code be used or do I have to combine the two things? when I wrap all of my divs with forms, it looks unresponsive (sorry, if my english so bad)

Custom comments template in BlogEngine

When someone wants to write a comment, It has to set Name, Email, Web Site and finally comments . How should I modify this template to use just the Comment? Because It has these info when admin registered him. I dont want to store false info.
Thanks for your help.
Since you didn't specify the version I am assuming you are running on the current latest (3.1).
The comment submission form is controlled by the CommentForm.cshtml in the siteroot/Custom/Theme/YourCurrentTheme folder. Here is a portion of the form from the Garland-Revisited theme.
<p>
<label for="txtName" class="lbl-user">#Resources.labels.name *</label>
<input type="text" class="txt-user" name="txtName" id="txtName" />
</p>
<p>
<label for="txtEmail" class="lbl-email">#Resources.labels.email *</label>
<input type="text" class="txt-email" id="txtEmail" />
</p>
<p id="commentCompose">
<textarea class="txt-content" id="txtContent" cols="50" rows="10" name="txtContent"></textarea>
</p>
The simplest path is probably to avoid changing the submission handler and convert the input type to hidden and prefill the value with their logged in credentials. A possible sample.
<input type="hidden" id="txtName" value="#SomeC#CodeToReadTheValuesFromTheLoggedInInformation" />
<input type="hidden" id="txtEmail" value="#SomeC#CodeToReadTheValuesFromTheLoggedInInformation" />
<p id="commentCompose">
<textarea class="txt-content" id="txtContent" cols="50" rows="10" name="txtContent"></textarea>
</p>
This does have security implications. You are trusting your users not to mess with the hidden values in the form. On an open website this probably isn't safe enough and you will have to look at changing the submit handler.
Changing the submit handler does have its own maintenance issues since you will be running a custom version of the software that won't upgrade cleanly when the next version comes out. It's up to you to decide what is the better path in your situation.

Hidden inputs are missing from Request in Asp.net mvc3

I'm using asp.net mvc3 ajax.beginform, and recently I've encountered a very strange problem.
It seems that some of the hidden input's I've placed inside the form do not exist in the request object.
I am not changing these values in any way after the post.
Any idea what is the reason?
Here's an example of a form that's giving me some trouble.
<form action="/PriceListItems/PriceUpdate" data-ajax="true" data-ajax-method="Post" id="form0" method="post">
<input id="item_Id" name="item.Id" type="hidden" value="3">
<input id="price_TariffId" name="price.TariffId" type="hidden" value="1">
<input class="input-mini"
data-val="true"
data-val-number="The field Price must be a number."
data-val-regex="incorrect number"
data-val-regex-pattern="(^N/A$)|(^[-]?(\d+)(\.\d{0,3})?$)|(^[-]?(\d{1,3},(\d{3},)*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{1,3})?)$)"
data-val-required="שדה זה הינו חובה"
id="itemTariff_3_1"
name="price.Price"
onchange="postThis(this);"
type="text"
value="300.00">
<span class="help-block">
<span class="field-validation-valid"
data-valmsg-for="itemTariff_3_1"
data-valmsg-replace="true"></span>
</span>
</form>
Thanks!
solved it, but it was quite a disappointing solution..:
i've replaced every jquery related script in my site so that it'll arrive from a CDN rather from my local files, but in the original versions.
and that was it.
everything suddenly started to click together.
frustrating, but works.
thanks,
Nir

Form action submit but NOT redirect (facebook static + magento)

This seems simple enough but there are complications...
I have a facebook FBML static page where I want users to sign up to my magento newsletter.
I think I'm right in saying typically you can put the form code as below into the fbml page and on submit it will add the user to the newsletter;
<form action="http://my-site.com/newsletter/subscriber/new/" method="post" id="newsletter-validate-detail">
<fieldset class="block-content">
<legend>Newsletter</legend>
<label id="newsletter-label" for="newsletter" class="left">Join our mailing list</label>
<div class="input-box left">
<input name="email" type="text" id="newsletter" class="input-text required-entry validate-email" />
</div>
<button id="newsletter-submit" type="submit" class="button btn-submit"><span>Join</span></button>
</fieldset>
</form>
But of course at my site I have an ajax function that returns a thanks for registering, so when this submit is sent from fb, this just lands me at a confirmation message on my domain that is supposed to feed through java and say thanks very much for signing up.
So what I need is some way of posting the action, but keeping the user on facebook, or at least leaving them at some other landing page after the action.
Something that posts but doesn't redirect, or something that posts then redirects to something other than the url in the form action?
Not sure if I need ajax for this or if js is even allowed within the fb environment, could I use any of their proprietary FBML to achieve this?
Many thanks
Could you add onSubmit="handleData(); return false;" to your form so it doesn't submit? and use the handleData() function to proccess the data in whatever way you need? This will keep the user from moving off the current page.

Resources