I have a registration form with 50+ input fields. What is the best way to get form filed information to pass it to iPhone or Android developers to make a form in the mobile app?

Currently i am doing something like inspect the form with firebug and copy/paste the form to make this work.

Recently i have written some code to get the form field information.

This is the idea.

  1. In the hook_formalter add a $form['#after_build'][]
  2. Get the keys in $form['#after_build'][] and get the basic information.
  3. Render the information to a item and add it to form so that i can copy/paste

But its not perfect; when the form fields like add custom modules for Registration like Logintoboggan etc i am not getting expected results.

What is your way to do it?

This is the result i expect in case of a select field

                [Title] => Marital Status
                [Field Name] => field_marital_status[und]
                [Type] => select
                [Options] => Array
                     [151] => Status
                     [154] => -Divorced
                     [155] => -Married
                     [153] => -Never married before
                     [157] => -Separated
                     [156] => -Widowed


  • 3
    It might not be the answer you're looking for, but quite simply the best way is to write your own service resource. There's the Services Views module but it's buggy as hell, I always, always write my own these days. It takes no time at all and I can give exactly what the consumers of the service need, not the 'best effort' that you get with the services module out of the box
    – Clive
    Feb 14, 2013 at 13:16
  • 1
    @Clive, thanks for noticing this. I am waiting for SOME solution. And i made one myself. But its not perfect. I will post it somewhere and give you link soon. Lets wait for some answer.
    – niksmac
    Feb 14, 2013 at 13:53
  • drupal_get_form() will get array of form that passed all modules alterations. So you should write function that clear out unusable properties and post it to rest answer...
    – Nikit
    Feb 14, 2013 at 23:08
  • @Nikit, can you please read my query fully ?
    – niksmac
    Feb 15, 2013 at 2:37

1 Answer 1


As @Clive has suggested in comment its best to write your own service resource for this.

Approach 1:

But i wouldn't bother to programaticality supply the form field values anymore. Reason being, its usually not cost-effective to spend enough hours trying to figure out every possible field type that has been implemented or may be implemented in the future.

Instead create an API documentation. The implementation details is the liberty of IPad / Android dudes. Make sure you enable version control over the docs and also maintain a well documented change logs.

Approach 2:

If you do want to supply the form field information via services.

Then create a resource action.

Something like www.mysite.com/your-endpoint-name/your-resource-name/get-form

This action should be responsible to provide the field details.

This could be done by calling drupal_get_form($form_id); and then passing the $form array through a function that would filter out lots of unnecessary data which drupal adds.

Please note that the main difference here is "We are removing unwanted data from the form definitions" instead of "adding necessary field data". Thus it will help reducing missing fields that might be added later by some modules in to the form.

After you are done with removing you may add additinal information into the form array like API interface Version, timestamp, and some default values that maybe useful for the Ipad/android dudes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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