i have created a country select box as
$country= new Zend_Form_Element_Select('country');
in my user registration form ..
While selecting an country an ajax call is send and getting the state list
by creating another select box
$state= new Zend_Form_Element_Select('state');
in another action say stateAction()
Problem is that when i tried to validate registration form in the POST action
i cant retrieve the value from state
$form = new Users_Form_Register();
eg as $userObjectDetails->statename=$form->getValue('state');
as a solution i added tried to added a dummy variable $state in Users_Form_Register();
add addElement($state),unfortunately during value is loaded by ajax call the state list issue occure during validation of the form
please suggest a solution for the above
Thank you
You could try validating with javascript. jQuery has a nice validation plugin that lets you attach the validator to the form ID and define the rules you want to validate.
Related
I'm trying to set up a third party payment service with my React application.
https://developer.bambora.com/europe/sdk/web-sdk/checkout-integration
I'm trying to figure out how to send form data onSubmit as an object to pre-populate form fields on the Bambora redirect URL page.
I'm thinking that I have to create a state object, populate it onSubmit of the fields, if valid pass it to the RedirectCheckout() somehow. I'm not sure how to do that last part.
import { RedirectCheckout } from "#bambora/checkout-sdk-web";
....
new RedirectCheckout("<<YOUR-SESSION-TOKEN-HERE>>")
This was solved by using the checkout link generator from Bambora and creating a hash function using the params they used in their hash function for validation for the link.
In moodle, when you go to Quiz Administration-> User overrides -> Add user override, you get a form (overrideedit.php) to add the details of the user override to be created.
You need to fill that form and submit it. After you submit, the form is processed (in overrideedit.php itself) and then you are redirected to overrides.php page.
Now, I want that form to take post data from my plugin and process it in overrideedit.php and do the redirect.
How do I send post data in this case from my plugin?
You could set a different action for the form you're having in your plugin (this assumes you are using Moodle Form API for your custom form):
// Instantiate your form
// Data will be submitted to /mod/quiz/overrideedit.php
$mform = new custom_form_your_are_having(new moodle_url('/mod/quiz/overrideedit.php'));
Or simply change the action attribute of your custom for to point to /mod/quiz/overrideedit.php:
<form action="/mod/quiz/overrideedit.php" method="post">
...
</form>
I currently have an Angular 2 app where the user can submit a form to create a new item. When the submit button is clicked, it calls a function that sends the data to the server and navigates to a new page when the server confirms that the data has been saved successfully.
My problem comes because the form submission appends the form parameters to the URL. So for example if I had an input named title and submission took me to the route mytitle which is the input for the title field, Angular (or whatever injects the GET parameters) would try to navigate to mysite.com/mytitle?title=mytitle instead of just mysite.com/mytitle. Even adding [ngModelOptions]="{standalone: true}" to all of my inputs still leaves a question mark with no parameters after it.
This is a problem because it causes Angular to reload the app because the given route does not match any routes in my route definitions. Is there a way to disable the GET parameters being injected into the URL entirely? POST doesn't work either because I have nowhere to post to, and my next URL uses data from the form itself.
I found an answer to my question, the "Submit" button defaulted to being of type "submit", so changing it to type "button" removed the GET parameters injection behavior.
Check setValue in your form control. Example: Set value this way this.form.controls['val'].setValue='' rather than assigning an empty value
(i.e. this.form.controls['val'] == 0).
If your problem still exists, kindly add button type submit to the button and manually give the click function access to it.
Drupal 7, I want to load the user profile form into a module page. I have a custom field also that the user can configure, let's call this field "blah". It's a implemented as a dropdown field.
When I load the form using the following code everything is fine apart from the blah field which does not populate its user stored data.
form_load_include($form_state, 'inc', 'user', 'user.pages');
global $user;
$output .= drupal_render((drupal_get_form('user_profile_form', $user)));
Does anyone know how I would get the blah variable/value/user data into this rendered form? It is populated if I go to the standard user profile editing page at http://example.com/user/2/edit.
You should be able to achieve this using user_load api.
global $user;
$user_fields = user_load($user->uid);
print_r($user_fields);
Solved it! I think the very act of posting on Stack Overflow sometimes brings you around to working it out. It was just as simple as $user->field_blah['und'][0]['value'] = 12345;
Possible Solutions:-
1)If its a custom field make it belong to user entity bundle and true for user register form while attaching it to user bunble.
2)U can use field_attach_form,
3)form alter
I would like to make a "preview container" for form values in Yii. (so every time the user finishes entering data, the "preview container" below the form will display them, to let the user knows how the item actually looks like).
To achieve this, the only way is to call a Javascript function to update the "preview container" (using jQuery). The CActiveForm is:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id'=>'item-form',
'enableAjaxValidation'=>true,
));
?>
How do we modify it to call a javascript function each time the fields are validated?
(Note: whenever we switch between the input fields, the fields are validated dues to enableAjaxValidation=>true)
Thanks in advanced.
With jQuery you can define your own listener functions for the fields you want to update, which is probably going to be cleaner than trying to hook into the validation functions.You could monitor onchange or blur or whatever is most appropriate to your data.
The js can be loaded via Yii's registerScript function or, again, whatever is most appropriate for your app. A listener function would normally be loaded on DOM ready, i.e., with the POS_READY attribute for registerScript.
You can search the tutorials as well as this basic tutorial for more info.