I have a contact form on my site. I use formit for its FormIT validation. I want email be not more than 40 characters, be reqired and be correct email address. Message field is required too and has max length set.
Validator doesn't work correctly:
When required fields are empty, it shows error message and doesn't allow to send the form (this situation is absolutely correct)
When in email is any text (valid or not), form is sent but redirect to success page doesn't work (so it happens also when we enter more than max length)
[[!FormIt?
&hooks=`spam,email,redirect,FormItAutoResponder`
&emailTpl=`emailTplContact`
&emailSubject=`Message from site.com`
&emailTo=`myemail#gmail.com`
&validate=`email:email:required:maxLength=^40^,
message:required:maxLength=^150^`
&redirectTo=`11`
&fiarTpl=`emailAutoRespond`
&fiarSubject=`Your message is sent`
&fiarFromName=`My Site`
&fiarFrom=`myemail#gmail.com`
&fiarToField=`email`
&fiarReplyTo=`email`
]]
<form id="contact-form" method="post" action="[[~[[*id]]]]" enctype="application/x-www-form-urlencoded" role="form" data-toggle="validator" name="order">
<input type="text" id="name" name="name" type="name" placeholder="Name" value="[[!+fx.name]]" size=25>
<input type="text" required="required" type="email" id="email" name="email" placeholder="Email" value="[[!+fx.email]]">
[[!+fx.error.email]]
<textarea required="required" placeholder="Message" id="message" name="message">[[!+fx.message]]</textarea>
<button name="send">Send</button>
</form>
</div>
You have type attribute twice in the name input and the email input, so that might be the problem.
<input type="text" id="name" name="name" type="name">
<input type="text" required="required" type="email">
Remove type="name" and type="email" -- (leave type="text")
Also - I have only ever used a prefix of fi for Formit placeholders; do you know for sure that fx will work? Did you set that somewhere else? You say you're seeing the error message so I guess the error placeholder must be working...
Be sure to add placeholderPrefix to your FormIt call:
[[!FormIt?
&placeholderPrefix=`fx`
&hooks=`spam,email,redirect,FormItAutoResponder`
&emailTpl=`emailTplContact`
&emailSubject=`Message from site.com`
&emailTo=`myemail#gmail.com`
&validate=`email:email:required:maxLength=^40^,
message:required:maxLength=^150^`
&redirectTo=`11`
&fiarTpl=`emailAutoRespond`
&fiarSubject=`Your message is sent`
&fiarFromName=`My Site`
&fiarFrom=`myemail#gmail.com`
&fiarToField=`email`
&fiarReplyTo=`email`
]]
Related
I have a Wicket page with this structure:
<form wicket:id="generalForm" method="post" class="form_recherche">
<input value="" type="text" wicket:id="myField_1" />
<form wicket:id="innerForm" method="post">
<input value="" type="text" wicket:id="myField_2"/>
<input type="submit" class="button-classic" wicket:id="accept_2"/>
</form>
<input type="submit" class="button-classic" wicket:id="accept_1" />
</form>
1 external form with 1 inner form. One field each. The fact is that when the "accept_2" button is clicked, the field "myField_1" is not submitted to the server (only the "myField_2" is submitted). And in fact, I would need the "field_1" field to do some validation.
What am I missing and why isn't the "myField_1" being filled on the server why "accept_2" is clicked?
You need to override Form#wantSubmitOnNestedFormSubmit() on the outer Form to return true. This way you will tell Wicket that you want the (outer) form to be submitted as well when one of its nested forms is submitted.
You used SO tags wicket-1.5 and wicket-1.6. I am not sure whether this method is available for your version of Wicket.
I am trying to create a form with Craft that allows users to rate entries in a specific section. The section that tracks the ratings has three fields: the ratings drop-down field, a user field, and an entry field. Here is my form right now:
<form method="post" accept-charset="UTF-8">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="entries/saveEntry">
<input type="hidden" name="redirect" value="viewentry/{slug}">
<input type="hidden" name="sectionId" value="userRatings">
<input type="hidden" name="enabled" value="1">
<input type="text" id="user" name="ratings" value="{{currentUser}}" style="display:none;" readonly>
<input type="text" id="restaurant" name="restaurant" value="{{entry.id}}" style="display:none;" readonly>
<label for="ratings">Rate This Restaurant</label>
<select id="ratings" name="ratings" required>
{% for option in entry.ratings.options %}
<option value="{{ option.value }}">{{option.label}}</option>
{% endfor %}
</select>
<input class="button" type="submit" value="Rate">
I have two text boxes that are recording the current user and the Entry ID of the entry I am trying to rate (we are on the _entry.html for this entry). Before I added the "display:none" they were both showing the correct information. Then I am pulling the options for the ratings field that I set in craft and setting them as the values for the drop down here (which is working).
When I try to submit I get a craft error: "Internal Server Error Trying to get property of non-object." Any help or suggestions would be greatly appreciated!
You're missing the 'title' field ..
<input type="hidden" name="title" value="Free Registration Title">
It's a requirement
I have 2 forms on one page that I need to pass to the same page to assemble a pdf. How can I do that? I have tried using a action="post" for one and action="get" for the other, but I can't get that to work. I have tried assigning one form to session variables, but I can't get that either. Any suggestions??
<form name="formOne" id="formOne" method="post" action="#buildURL('goTothisPage.page')#">
<input name="name" id="name" autofocus="true" >
<input name="address" id="address" >
I would try just creating one big form instead of 2 smaller forms if the action is going to be the same and go to the same .cfm page. (Just expand the scope of your tags)
You can also create 2 "Submit" buttons (1 for each form) to make it appear as 2 separate forms, even though the buttons will submit the same form.
If it is required to have two separate forms in your html, it is also possible to forge the form values from one form into the other at the moment of the submit event.
HTML:
<form name="formOne" id="formOne" method="post">
<input name="name" id="name" type="text" >
<input name="address" id="addressHidden" type="hidden">
</form>
<form name="formTwo" id="formTwo" method="post">
<input name="address" id="address" type="text">
<input name="name" id="nameHidden" type="hidden" >
</form>
Javascript:
$(document).ready(function(){
$('#formOne').submit(function(event){
$('#addressHidden').val($('#address').val());
return true;
});
// same for #formTwo
$('#formTwo').submit(function(event){
$('#nameHidden').val($('#name').val());
return true;
});
});
I have a content type which is only viewable (not editable) to a certain role. I've customised the form output completely (manually outputting each field as they display in a certain way).
However there's one field I would like this user to be able to 'edit' which is a custom 'revision comment' field I've made. I can hardcode in the form fields, except of course it won't work without the token, build id etc that Drupal generates like this:
<input type="hidden" name="form_build_id" value="<?php print render($form['#build_id']); ?>">
<input type="hidden" name="form_token" value="<?php print drupal_get_token($form['#token']); ?>">
<input type="hidden" name="form_id" value="<?php print render($form['#form_id']); ?>">
So essentially I'm wondering what workaround I could use, as $form and it's variable are obviously only generated when 'editing' the node.
In case anyone else needs to know, I hardcoded this into the template file and it works:
<form class="node-form node-project-form" action="/dashboard" method="post" id="project-node-form" accept-charset="UTF-8">
<input type="hidden" name="nid" value="<?php print $nodeid; ?>">
<input type="hidden" name="uid" value="<?php print $user->uid; ?>">
<div id="revision-comments" style="margin:0">
<label for="log-comments">Log Message</label>
<textarea id="log-comments" name="log_comments"" cols="60" rows="4" class="form-textarea"></textarea>
</div>
<input type="submit" id="edit-submit" name="op" value="Post Comment" class="form-submit">
</form>
We have the following code in which we are getting errors in the w3c validator for "Any input descendant of a label element with a for attribute must have an ID value that matches that for attribute." and "The label element may contain at most one input, button, select, textarea, or keygen descendant." Is this something that should just be ignored by the validator (as it is seeminlgly correct) or should it be changed to appease the w3c? Note this is html5 doctype.
<fieldset>
<label for="user_is_subscribed">
<input type="hidden" value="0" name="user[is_subscribed]">
<input type="checkbox" value="1" name="user[is_subscribed]" id="user_is_subscribed">
Newsletter Signup
</label>
<span class="checkLabel">We will never spam or give away your information</span>
</fieldset>
Thank in advance!
Labels should contain at most one input element. Move the hidden input out of the label. Also, when an input is a descendant of a label, the for attribute is superfluous.
<fieldset>
<input type="hidden" value="0" name="user[is_subscribed]">
<label>
<input type="checkbox" value="1" name="user[is_subscribed]" id="user_is_subscribed">
Newsletter Signup
</label>
<span class="checkLabel">We will never spam or give away your information</span>
</fieldset>
Is this something that should just be ignored by the validator
No
(as it is seeminlgly correct)
It isn't
or should it be changed
Yes
to appease the w3c?
No. It should be changed because it is wrong, and browsers have to error correct to figure out which element the label is associated with.
The label isn't labeling the hidden input, move it elsewhere.