Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:13:41+00:00 2026-05-27T01:13:41+00:00

I have a form implemented from hook_form called simplequiz_form() I want to access its

  • 0

I have a form implemented from hook_form called simplequiz_form() I want to access its data after submit below is the code I have written but I can’t seem to access its data once its submitted. What am I doing wrong ?

function simplequiz_form_validate($form, &$form_state) {
// here  is where we will validate the data and save  it in the db.
$thid = db_insert('simplequiz')
->fields(array(

'questions' => &$form_state['question'],
**I can't seem to access the value of a field questions** 

))
->execute();

 return $thid;
 }

Below is my implementation of hook_form()

function simplequiz_form($form, &$form_submit)
{ 

$form['question'] = array(
'#title' => t('Please input your question'),
'#type' => 'text_format',
'#required' => FALSE,
'#description' => t('Here is where you can enter your questions'),    
);

$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;

}

if I use $form_state[‘values’][‘question’]

I get the below error:

PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn’t match value count at row 1: INSERT INTO {simplequiz} (questions) VALUES (:db_insert_placeholder_0_value, :db_insert_placeholder_0_format); Array ( [:db_insert_placeholder_0_value] => [:db_insert_placeholder_0_format] => filtered_html ) in simplequiz_form_submit() (line 245 of /home/vishal/Dropbox/sites/dev/sites/all/modules/simplequiz/simplequiz.module).

it worked using $form_state[‘values’][‘question’][‘value’]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:13:42+00:00Added an answer on May 27, 2026 at 1:13 am

    It’s best practice to use hook_form_validate, just for validation purposes, anything other than validation should be done in hook_form_submit.

    Either way they both function almost the same way.

    All the form data is stored in $form_state['values'], so to access $form['questions'] values, just use $form_state['values']['questions'].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with most of its functionality implemented using standard TAction. I
I have the following code that returns rows from a database when a form
I have implemented a custom designer class which inherits from DocumentDesigner. The standard Form
I have CustomForm inherited from Form which implements a boolean property named Prop .
I have a simple form on a view page, implemented as a user control,
I have form with one input for email and two submit buttons to subscribe
I have a custom form implemented in a custom module in drupal 6. The
I have installed and implemented the plugin restful_authentication from technoweenie. My application is, for
I have a form that is displayed, not by ShowDialog, but by setting its
I have implemented an Android code that calls a SOAP web service. The web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.