To add multiple steps before submit form. like:
Registration page:
Step 1 - Enter first, last name and email (validate on click of next button and show next step)
Step 2 - Enter Password and Confirm password and submit
Step 1 and step 2 are separate DIV's (Show/hide on Next Click)
You can give a try of this JS snippet:
var formToValidate = $('place the id of the form, that I want to validate');
var validator = new Validation(formToValidate);
if(validator.validate()) {
/* The logic, that you want to execute if you pass the validation. */
......
......
}
Good luck!
Related
Drupal 7
Webform 7.x-4.15
Example:
Webform 1: Fill up Particular
Webform 2: Category details
When a user submits the first webform 1, I have the confirmation page there I have a listing (For the first time is empty), when I click on another button that is in this page I redirect to second form here I will pass at the same time the last user ID save (SID)
How can I make a relationship between the forms (Webform 1 and Webform 2)?
Schema relationship between two forms
You can add custom submit callback and go to next form with it.
hook_form_alter
function MYMODULE_form_alter(&$form, &$form_state, $form_id){
if($form_id == 'id_step_one'){
$form['#submit'][] = '__custom_submit_function'; // add callback submit
}
}
function __custom_submit_function($form, &$form_state){
// do some stuff if you want
drupal_goto('/your_form_step2'); // redirect to step 2 of webform
}
Good morning!
I need to post a form, I've already changed all the values inside that form (drop-drown list, text fields , check-boxes, etc), in this way:
final HtmlPage page4 = webClient.getPage("somepagemakinmemad");
HtmlForm formx= page4.getFormByName("lista_grupos");
changing values like:
HtmlSelect duracion = (HtmlSelect) page4.getElementByName("p_duracion_"+datum.getCrn()+"_1");
HtmlOption option1 = duracion.getOptionByValue("0029_029");
duracion.setSelectedAttribute(option1, true);
That is, I am changing the values through obtaining the html element from the page, not through the form (is that okay anyway?).
And then I try to submit the form, through:
<input id="p_guardar" class="boton" type="button" onclick="validaAPG()" value="Guardar">
Which is the "button-like" input where someone clicks when is over with the form.
I have to say, when I print the html code of the form, with "asXml()", I see the form the with selected values I've intended to select.
Question: How can I click on that button and send the form? That input runs a script, when clicked
Thanks everyone, let me know if you need any other kind of info.
You can use below code to click on the button to submit the form.
HtmlButtonInput button = (HtmlButtonInput)page.getElementById("p_guardar");
page = button.click();
You dnt need to care what script runs when clicked.If you dont need to run the script remove the attribute.
When inside a webform, that was created with the module webform - I need to validate / check the entries of a page when submit/"next step" is clicked- So before the user moves to the next page(pagebreak).
I want to check if the email address was entered already - if so show this as an error without moving to the next page.
I need a hook .. or a way to tell drupal "go to step 1" instead of showing step 2.
You can use a hook to check the value of the form. In hook form alter you can check your field values.
$form['#validate'][] = 'function_to_validate_field';
function check_for_company_validate($form, &$form_state) {
//do stuff
}
You can see this for drupal 7 to create an error:
https://api.drupal.org/api/drupal/includes!form.inc/function/form_set_error/7
I use symfony admin generator to create a very long form.
This form is so long, that users hesitate to start completing.
I need to make small steps in fill in :
example: First form: step 1 : organization
Second form: step 2: name and occupation
Third form: step 3: solution
....
Tenth form step 10: memo
Every step has a submit button to save another portion/part of the form.
Do you have any ideas how to realize that ?
Thank you
I would create 10 different forms (and actions in the controller), and when each part is completed (and validated) redirect to the next part of the form's controller action.
under Plone4/Zope3, I have a form to add a new object.
I'd like to add a button after the first field, to do the following :
- the user enters the value for the first field
- he presses this new button
- and the server will try to guess the remaining field based on the first field and an external database.
- the user will then have to check if all fields are OK and then submit the form.
I am not a zope expert, and spent some time trying to figure out how to do this.
Is creating a subform a good idea ?
If not, I could add a new button to the form : I tried something like
#button.buttonAndHandler(_(u'Essai'))
def essai(self, action):
print "button essai"
but then I have the following issues :
- how to render the button after the first field and not at the bottom ?
- how to update the remaining fields without submitting the form ?
- how to keep the "add" and "cancel" button that disappeared when I added this essai button.
any hints ?
Thx
I suggest to use javascript to solve this. With jquery you can include an extra button directly behind your first field (http://api.jquery.com/after). In the button action ask a browser view for the search results in json (http://docs.python.org/library/json.html) an fill up the other form fields, like:
jq('my-button').click(function(event) {
event.preventDefault();
var first_field= jq('#first-field-id').val();
jq.getJSON('/##my-browser-view?value=' + value, function(result) {
jq('#other-field-id').val(result.val_for_other_field);
...
});
});