0

I am trying to create a module with a simple form. The form allows the user to enter their address, from there I need to take the user's address, make a geocoding request, then send the data to another api, and then I need to display the data from the api request. The part I am having issues with is taking the submitted address so I can do the requests with it. How do I take the data from the form so I can use it? I do not need or want to save the data into my database.

Thanks in advance.

1

In the form submit handler, look in the form state. The values array will contain submitted values.

So for a form element, 'foo', generated like this:

$form['foo'] = [
  '#type' => 'textfield',
  '#title' => t('Foo'),
];

You get the value like this:

function MYMODULE_form_submit($form, &$form_state) {
  $value_of_foo_field = $form_state['values']['foo'];
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.