forms

Issue with Django-forms: 'WSGIRequest' object has no attribute 'get'

混江龙づ霸主 提交于 2021-01-27 14:18:56
问题 I am getting this error in the Django debug-view: 'WSGIRequest' object has no attribute 'get' This is for a login-script, which most of is copied from the admin-code, mostly for practice/tweaking-reasons. The code I have, in views.py, is following: @sensitive_post_parameters() @csrf_protect @never_cache def login(request, template_name="main/login.html", authentication_form=LoginForm, redirect_field_name=REDIRECT_FIELD_NAME, current_app=None, extra_context=None): """ Displays the login form

How to prevent spam URLs in a PHP contact form

前提是你 提交于 2021-01-27 13:13:25
问题 I have created a form where a user can add a review. Perhaps this is very obvious but how can I avoid a user inserting a url in the text area. Is there a way to check this? I have put in a captcha to check for humans. <form action="" method="POST" name="form"> some other input fields <span id="sprytextarea1"> <textarea name="Comments" cols="50" rows="3" ></textarea> <span class="textareaRequiredMsg">A value is required.</span></span></p> <img id="captcha" src="/securimage/securimage_show.php"

Detect Ajax in PHP

China☆狼群 提交于 2021-01-27 13:05:13
问题 I am trying to make an ajax post to the same php page. Ajax: $("#loginForm").submit(function(e) { e.preventDefault(); var postData = $(this).serialize(); $.post("login.php", postData); }); The postData is correct and is in the following format: username=john&password=123123 PHP (same page): if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo 'Ajax Request Detected'; } However this if-check always returns false and the echo

Django Accepting AM/PM As Form Input

十年热恋 提交于 2021-01-27 12:43:33
问题 I am trying to figure out how to accept am/pm as a time format in Django using a DateTime field, but I am having some trouble. I have tried setting it like this in my forms.py file pickup_date_time_from = DateTimeField(input_formats=["%m/%d/%Y %I:%M %p"]) with the following data: 12/31/2017 02:40 pm However, I get a validation error when submitting the form: (Hidden field pickup_date_time_from) Enter a valid date/time. I have also tried setting a global variable in settings.py as the

Adding a bootstrap class to rails form time_select field

佐手、 提交于 2021-01-27 12:26:59
问题 Bootstrap has the class 'form-control' to add to select boxes to give them styling. I was able to do it successfully so for the following field: <%= f.collection_select :team_a_id, @teams, :id, :name, {prompt: "Select first team"}, {class: "form-control"} %> However I have the following form field for time_select. I need to apply an html class(preferably "form-control") to the following form field and have not been successful in doing so with the same approach above. <%= f.time_select :match

Submit Canvas Data in an HTML Form

笑着哭i 提交于 2021-01-27 12:16:26
问题 How can I submit Canvas content inside a PHP CodeIgniter form? One of the inputs on my form is a Canvas for a drawing or webcam photo. I created a tag <input name="picture" type="hidden"> and set its value to the base64 content: myPictureInput.value = canvas.toDataURL(); However, when the user submits the form, the POST value read from the <input> is truncated to 64kb. Is there an optimal way to post or submit images together with form data? 回答1: As mentioned in this answer, you should send

'Twig_Error_Syntax' with message Unknown “form_start” function

蹲街弑〆低调 提交于 2021-01-27 11:44:53
问题 Is it possible to make a standalone form with symfony3 and twig? I can't get past this error: Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "form_start" function in "new.html.twig" at line 1 The 3.1 documentation cites this example, which works fine, but it's actually using 2.7 My simple project is organized like this: . ├── composer.json ├── composer.lock ├── src │ └── form.php ├── vendor │ └── ... └── views └── new.html.twig form.php <?php require_once __DIR__.'/

Change input value based on another input's value

大城市里の小女人 提交于 2021-01-27 11:44:16
问题 hope that title makes sense. I'm a noob at javascript. What I want to do is have a form which will have a couple of inputs like, name and url for example. When the user enters their name, I'd like the url input to automatically have as a default their name with an underscore between words. So if they type in as their name pedro kinkybottom then automatically set as the default in the url input would be pedro_kinkybottom. I'm using cakephp if anyone happens to know a particularly cakey way to

Drupal 8 add ajax form element after ajax callback

时光怂恿深爱的人放手 提交于 2021-01-27 11:43:37
问题 I am building a drupal form with multiple ajax enabled form elements. I have one select list that does an ajax callback after change. The problem is that it adds a new select list to the page, which is also ajax enabled. This does not seem to work, which seems logical to me because the ajax is actually bundled an added to the page so it is lost in the replacecommand. Is there anyone experienced with this, and does anyone have a solution ? This is my code /** * {@inheritdoc} */ public function

Change input value based on another input's value

可紊 提交于 2021-01-27 11:43:36
问题 hope that title makes sense. I'm a noob at javascript. What I want to do is have a form which will have a couple of inputs like, name and url for example. When the user enters their name, I'd like the url input to automatically have as a default their name with an underscore between words. So if they type in as their name pedro kinkybottom then automatically set as the default in the url input would be pedro_kinkybottom. I'm using cakephp if anyone happens to know a particularly cakey way to