0

I am using webform of version "7.x-3.18+24-dev" and I have altered the webform to add my custom fields like date drop-down(for day,month and year) but these components are not getting stored in database. Does anyone know why its happening. I am attaching my code here for reference .

   function scfhp_grievanceform_form_alter(&$form, &$form_state, $form_id) {
    switch ($form_id) {
    /* for chinese */
     case 'webform_client_form_71989':
        $form['submitted']['dob'] = array(
            '#type' => 'fieldset',
            '#title' => t('出生日期'),
            '#weight' => 4,
            '#prefix' => '<div class="chinese_dob" id="webform_chinese_dob">',
            '#suffix' => '</div>',
            '#required' => 'true'
        );

        $form['submitted']['dob']['dob_month'] = array(
            '#type' => 'select',
            '#default_value' => array('month' => '月'),
            '#options' => array('month' => t('月'),
                1 => t('1 月'), 2 => t('2 月'), 3 => t('3 月'), 4 => t('4 月'), 5 => t('5 月'), 6 => t('6 月'), 7 => t('7 月'), 8 => t('8 月'), 9 => t('9 月'), 10 => t('10 月'), 11 => t('11 月'), 12 => t('12 月'),
            ),
            '#description' => t('Select month.'),
            '#required' => true,
        );

        /* for 31 days */
        $form['submitted']['dob']['dob_day_31'] = array(
            '#type' => 'select',
            '#default_value' => array('day' => '日'),
            '#options' => array('day' => t('日'), 1 => t('1'), 2 => t('2'), 3 => t('3'), 4 => t('4'), 5 => t('5'), 6 => t('6'), 7 => t('7'), 8 => t('8'), 9 => t('9'), 10 => t('10'), 11 => t('11'), 12 => t('12'),
                13 => t('13'), 14 => t('14'), 15 => t('15'), 16 => t('16'), 17 => t('17'), 18 => t('18'), 19 => t('19'), 20 => t('20'), 21 => t('21'), 22 => t('22'), 23 => t('23'), 24 => t('24'),
                25 => t('25'), 26 => t('26'), 27 => t('27'), 28 => t('28'), 29 => t('29'), 30 => t('30'), 31 => t('31')),
            '#description' => t("Thirty-One Days."),
            '#required' => true,
        );

        $form['submitted']['dob']['dob_year'] = array(
            '#type' => 'select',
            '#default_value' => array('year' => '年'),
            '#options' => array('year' => t('年'), 1 => t('2013'), 2 => t('2012'), 3 => t('2011'), 4 => t('2010'), 5 => t('2009'), 6 => t('2008'), 7 => t('2007'), 8 => t('2006'),
                9 => t('2005'), 10 => t('2004'), 11 => t('2003'), 12 => t('2002'), 13 => t('2001'), 14 => t('2000'), 15 => t('1999'), 16 => t('1998'), 17 => t('1997'),
                18 => t('1996'), 19 => t('1995'), 20 => t('1994'), 21 => t('1993'), 22 => t('1992'), 23 => t('1991'), 24 => t('1990'), 25 => t('1989'), 26 => t('1988'),
                27 => t('1987'), 28 => t('1986'), 29 => t('1985'), 30 => t('1984'), 31 => t('1983'), 32 => t('1982'), 33 => t('1981'), 34 => t('1980'), 35 => t('1979'), 36 => t('1978'), 37 => t('1977'), 38 => t('1975'),
                39 => t('1974'), 40 => t('1973'), 41 => t('1972'), 42 => t('1971'), 43 => t('1970'), 44 => t('1969'), 45 => t('1968'), 46 => t('1967'), 47 => t('1966'),
                48 => t('1965'), 49 => t('1964'), 50 => t('1963'), 51 => t('1962'), 52 => t('1961'), 53 => t('1960'), 54 => t('1959'), 55 => t('1958'), 56 => t('1957'),
                57 => t('1956'), 58 => t('1955'), 59 => t('1954'), 60 => t('1953'), 61 => t('1952'), 60 => t('1951'), 61 => t('1950'),
            ),
            '#description' => t('Select year.'),
            '#required' => true,
        );

        /* Add dropdown for Date Of Problem Field */

        $form['submitted']['dop'] = array(
            '#type' => 'fieldset',
            '#title' => t('出现问题的日期'),
            '#weight' => 12,
            '#prefix' => '<div class="chinese_dop">',
            '#suffix' => '</div>',
        );

        $form['submitted']['dop']['dop_month'] = array(
            '#type' => 'select',
            '#default_value' => array('pmonth' => '月'),
            '#options' => array('pmonth' => t('月'),
                1 => t('1 月'), 2 => t('2 月'), 3 => t('3 月'), 4 => t('4 月'), 5 => t('5 月'), 6 => t('6 月'), 7 => t('7 月'), 8 => t('8 月'), 9 => t('9 月'), 10 => t('10 月'), 11 => t('11 月'), 12 => t('12 月'),
            ),
            '#description' => t('Select month.'),
            '#required' => true,
        );

        /* for 31 days */
        $form['submitted']['dop']['dop_day_31'] = array(
            '#type' => 'select',
            '#default_value' => array('pday' => '日'),
            '#options' => array('pday' => '日', 1 => t('1'), 2 => t('2'), 3 => t('3'), 4 => t('4'), 5 => t('5'), 6 => t('6'), 7 => t('7'), 8 => t('8'), 9 => t('9'), 10 => t('10'), 11 => t('11'), 12 => t('12'),
                13 => t('13'), 14 => t('14'), 15 => t('15'), 16 => t('16'), 17 => t('17'), 18 => t('18'), 19 => t('19'), 20 => t('20'), 21 => t('21'), 22 => t('22'), 23 => t('23'), 24 => t('24'),
                25 => t('25'), 26 => t('26'), 27 => t('27'), 28 => t('28'), 29 => t('29'), 30 => t('30'), 31 => t('31')),
            '#description' => t("Thirty-One Days."),
            '#required' => true,
        );

        $form['submitted']['dop']['dop_year'] = array(
            '#type' => 'select',
            '#default_value' => array('pyear' => '年'),
            '#options' => array('pyear' => '年', 1 => t('2013'), 2 => t('2012'), 3 => t('2011'), 4 => t('2010'), 5 => t('2009'), 6 => t('2008'), 7 => t('2007'), 8 => t('2006'),
                9 => t('2005'), 10 => t('2004'), 11 => t('2003'), 12 => t('2002'), 13 => t('2001'), 14 => t('2000'), 15 => t('1999'), 16 => t('1998'), 17 => t('1997'),
                18 => t('1996'), 19 => t('1995'), 20 => t('1994'), 21 => t('1993'), 22 => t('1992'), 23 => t('1991'), 24 => t('1990'), 25 => t('1989'), 26 => t('1988'),
                27 => t('1987'), 28 => t('1986'), 29 => t('1985'), 30 => t('1984'), 31 => t('1983'), 32 => t('1982'), 33 => t('1981'), 34 => t('1980'), 35 => t('1979'), 36 => t('1978'), 37 => t('1977'), 38 => t('1975'),
                39 => t('1974'), 40 => t('1973'), 41 => t('1972'), 42 => t('1971'), 43 => t('1970'), 44 => t('1969'), 45 => t('1968'), 46 => t('1967'), 47 => t('1966'),
                48 => t('1965'), 49 => t('1964'), 50 => t('1963'), 51 => t('1962'), 52 => t('1961'), 53 => t('1960'), 54 => t('1959'), 55 => t('1958'), 56 => t('1957'),
                57 => t('1956'), 58 => t('1955'), 59 => t('1954'), 60 => t('1953'), 61 => t('1952'), 60 => t('1951'), 61 => t('1950'),
            ),
            '#description' => t('Select year.'),
            '#required' => true,
        );

        return $form;
        break;

    /* for vietnamese */
    case 'webform_client_form_71990' :
        $form['submitted']['dobv'] = array(
            '#type' => 'fieldset',
            '#title' => t('Ngày Sinh'),
            '#weight' => 4,
            '#prefix' => '<div class="vietnamese_dob" id="webform_vietnamese_dob">',
            '#suffix' => '</div>',
            '#required' => 'true'
        );

        $form['submitted']['dobv']['dob_monthv'] = array(
            '#type' => 'select',
            '#default_value' => array('month' => 'Tháng'),
            '#options' => array('month' => t('Tháng'),
                1 => t('tháng 1'), 2 => t('tháng 2'), 3 => t('tháng 3'), 4 => t('tháng 4'), 5 => t('tháng 5'), 6 => t('tháng 6'), 7 => t('tháng 7'), 8 => t('tháng 8'), 9 => t('tháng 9'), 10 => t('tháng 10'), 11 => t('tháng 11'), 12 => t('tháng 12'),
            ),
            '#description' => t('Select month.'),
            '#required' => true,
        );

        /* for 31 days */
        $form['submitted']['dobv']['vdob_day_31'] = array(
            '#type' => 'select',
            '#default_value' => array('day' => 'Ngày'),
            '#options' => array('day' => t('Ngày'), 1 => t('1'), 2 => t('2'), 3 => t('3'), 4 => t('4'), 5 => t('5'), 6 => t('6'), 7 => t('7'), 8 => t('8'), 9 => t('9'), 10 => t('10'), 11 => t('11'), 12 => t('12'),
                13 => t('13'), 14 => t('14'), 15 => t('15'), 16 => t('16'), 17 => t('17'), 18 => t('18'), 19 => t('19'), 20 => t('20'), 21 => t('21'), 22 => t('22'), 23 => t('23'), 24 => t('24'),
                25 => t('25'), 26 => t('26'), 27 => t('27'), 28 => t('28'), 29 => t('29'), 30 => t('30'), 31 => t('31')),
            '#description' => t("Thirty-One Days."),
            '#required' => true,
        );

        $form['submitted']['dobv']['dob_yearv'] = array(
            '#type' => 'select',
            '#default_value' => array('year' => 'Năm'),
            '#options' => array('year' => t('Năm'), 1 => t('2013'), 2 => t('2012'), 3 => t('2011'), 4 => t('2010'), 5 => t('2009'), 6 => t('2008'), 7 => t('2007'), 8 => t('2006'),
                9 => t('2005'), 10 => t('2004'), 11 => t('2003'), 12 => t('2002'), 13 => t('2001'), 14 => t('2000'), 15 => t('1999'), 16 => t('1998'), 17 => t('1997'),
                18 => t('1996'), 19 => t('1995'), 20 => t('1994'), 21 => t('1993'), 22 => t('1992'), 23 => t('1991'), 24 => t('1990'), 25 => t('1989'), 26 => t('1988'),
                27 => t('1987'), 28 => t('1986'), 29 => t('1985'), 30 => t('1984'), 31 => t('1983'), 32 => t('1982'), 33 => t('1981'), 34 => t('1980'), 35 => t('1979'), 36 => t('1978'), 37 => t('1977'), 38 => t('1975'),
                39 => t('1974'), 40 => t('1973'), 41 => t('1972'), 42 => t('1971'), 43 => t('1970'), 44 => t('1969'), 45 => t('1968'), 46 => t('1967'), 47 => t('1966'),
                48 => t('1965'), 49 => t('1964'), 50 => t('1963'), 51 => t('1962'), 52 => t('1961'), 53 => t('1960'), 54 => t('1959'), 55 => t('1958'), 56 => t('1957'),
                57 => t('1956'), 58 => t('1955'), 59 => t('1954'), 60 => t('1953'), 61 => t('1952'), 60 => t('1951'), 61 => t('1950'),
            ),
            '#description' => t('Select year.'),
            '#required' => true,
        );

        /* Add dropdown for Date Of Problem Field */

        $form['submitted']['dopv'] = array(
            '#type' => 'fieldset',
            '#title' => t('Ngày xảy ra vấn đề'),
            '#weight' => 11,
            '#prefix' => '<div class="vietnamese_dop">',
            '#suffix' => '</div>',
        );

        $form['submitted']['dopv']['dop_monthv'] = array(
            '#type' => 'select',
            '#default_value' => array('month' => 'Tháng'),
            '#options' => array('month' => t('Tháng'),
                1 => t('tháng 1'), 2 => t('tháng 2'), 3 => t('tháng 3'), 4 => t('tháng 4'), 5 => t('tháng 5'), 6 => t('tháng 6'), 7 => t('tháng 7'), 8 => t('tháng 8'), 9 => t('tháng 9'), 10 => t('tháng 10'), 11 => t('tháng 11'), 12 => t('tháng 12'),
            ),
            '#description' => t('Select month.'),
            '#required' => true,
        );

        /* for 31 days */
        $form['submitted']['dopv']['vdop_day_31'] = array(
            '#type' => 'select',
            '#default_value' => array('day' => 'Ngày'),
            '#options' => array('day' => t('Ngày'), 1 => t('1'), 2 => t('2'), 3 => t('3'), 4 => t('4'), 5 => t('5'), 6 => t('6'), 7 => t('7'), 8 => t('8'), 9 => t('9'), 10 => t('10'), 11 => t('11'), 12 => t('12'),
                13 => t('13'), 14 => t('14'), 15 => t('15'), 16 => t('16'), 17 => t('17'), 18 => t('18'), 19 => t('19'), 20 => t('20'), 21 => t('21'), 22 => t('22'), 23 => t('23'), 24 => t('24'),
                25 => t('25'), 26 => t('26'), 27 => t('27'), 28 => t('28'), 29 => t('29'), 30 => t('30'), 31 => t('31')),
            '#description' => t("Thirty-One Days."),
            '#required' => true,
        );

        $form['submitted']['dopv']['dop_yearv'] = array(
            '#type' => 'select',
            '#default_value' => array('year' => 'Năm'),
            '#options' => array('year' => t('Năm'), 1 => t('2013'), 2 => t('2012'), 3 => t('2011'), 4 => t('2010'), 5 => t('2009'), 6 => t('2008'), 7 => t('2007'), 8 => t('2006'),
                9 => t('2005'), 10 => t('2004'), 11 => t('2003'), 12 => t('2002'), 13 => t('2001'), 14 => t('2000'), 15 => t('1999'), 16 => t('1998'), 17 => t('1997'),
                18 => t('1996'), 19 => t('1995'), 20 => t('1994'), 21 => t('1993'), 22 => t('1992'), 23 => t('1991'), 24 => t('1990'), 25 => t('1989'), 26 => t('1988'),
                27 => t('1987'), 28 => t('1986'), 29 => t('1985'), 30 => t('1984'), 31 => t('1983'), 32 => t('1982'), 33 => t('1981'), 34 => t('1980'), 35 => t('1979'), 36 => t('1978'), 37 => t('1977'), 38 => t('1975'),
                39 => t('1974'), 40 => t('1973'), 41 => t('1972'), 42 => t('1971'), 43 => t('1970'), 44 => t('1969'), 45 => t('1968'), 46 => t('1967'), 47 => t('1966'),
                48 => t('1965'), 49 => t('1964'), 50 => t('1963'), 51 => t('1962'), 52 => t('1961'), 53 => t('1960'), 54 => t('1959'), 55 => t('1958'), 56 => t('1957'),
                57 => t('1956'), 58 => t('1955'), 59 => t('1954'), 60 => t('1953'), 61 => t('1952'), 60 => t('1951'), 61 => t('1950'),
            ),
            '#description' => t('Select year.'),
            '#required' => true,
        );

        return $form;
        break;
    /* for spanish */
    case 'webform_client_form_71991' :
        $form['submitted']['dobs'] = array(
            '#type' => 'fieldset',
            '#title' => t('Fecha de nacimiento'),
            '#weight' => 4,
            '#prefix' => '<div class="spanish_dob" id="webform_spanish_dob">',
            '#suffix' => '</div>',
            '#required' => 'true'
        );

        $form['submitted']['dobs']['dob_months'] = array(
            '#type' => 'select',
            '#default_value' => array('month' => 'Mes'),
            '#options' => array('month' => t('Mes'),
                1 => t('enero'), 2 => t('febrero'), 3 => t('marzo'), 4 => t('abril'), 5 => t('mayo'), 6 => t('junio'), 7 => t('julio'), 8 => t('agosto'), 9 => t('septiembre'), 10 => t('octubre'), 11 => t('noviembre'), 12 => t('diciembre'),
            ),
            '#description' => t('Select month.'),
            '#required' => true,
        );

        /* for 31 days */
        $form['submitted']['dobs']['sdob_day_31'] = array(
            '#type' => 'select',
            '#default_value' => array('day' => 'Día'),
            '#options' => array('day' => t('Día'), 1 => t('1'), 2 => t('2'), 3 => t('3'), 4 => t('4'), 5 => t('5'), 6 => t('6'), 7 => t('7'), 8 => t('8'), 9 => t('9'), 10 => t('10'), 11 => t('11'), 12 => t('12'),
                13 => t('13'), 14 => t('14'), 15 => t('15'), 16 => t('16'), 17 => t('17'), 18 => t('18'), 19 => t('19'), 20 => t('20'), 21 => t('21'), 22 => t('22'), 23 => t('23'), 24 => t('24'),
                25 => t('25'), 26 => t('26'), 27 => t('27'), 28 => t('28'), 29 => t('29'), 30 => t('30'), 31 => t('31')),
            '#description' => t("Thirty-One Days."),
            '#required' => true,
        );

        $form['submitted']['dobs']['dob_years'] = array(
            '#type' => 'select',
            '#default_value' => array('year' => 'Año'),
            '#options' => array('year' => t('Año'), 1 => t('2013'), 2 => t('2012'), 3 => t('2011'), 4 => t('2010'), 5 => t('2009'), 6 => t('2008'), 7 => t('2007'), 8 => t('2006'),
                9 => t('2005'), 10 => t('2004'), 11 => t('2003'), 12 => t('2002'), 13 => t('2001'), 14 => t('2000'), 15 => t('1999'), 16 => t('1998'), 17 => t('1997'),
                18 => t('1996'), 19 => t('1995'), 20 => t('1994'), 21 => t('1993'), 22 => t('1992'), 23 => t('1991'), 24 => t('1990'), 25 => t('1989'), 26 => t('1988'),
                27 => t('1987'), 28 => t('1986'), 29 => t('1985'), 30 => t('1984'), 31 => t('1983'), 32 => t('1982'), 33 => t('1981'), 34 => t('1980'), 35 => t('1979'), 36 => t('1978'), 37 => t('1977'), 38 => t('1975'),
                39 => t('1974'), 40 => t('1973'), 41 => t('1972'), 42 => t('1971'), 43 => t('1970'), 44 => t('1969'), 45 => t('1968'), 46 => t('1967'), 47 => t('1966'),
                48 => t('1965'), 49 => t('1964'), 50 => t('1963'), 51 => t('1962'), 52 => t('1961'), 53 => t('1960'), 54 => t('1959'), 55 => t('1958'), 56 => t('1957'),
                57 => t('1956'), 58 => t('1955'), 59 => t('1954'), 60 => t('1953'), 61 => t('1952'), 60 => t('1951'), 61 => t('1950'),
            ),
            '#description' => t('Select year.'),
            '#required' => true,
        );

        /* Add dropdown for Date Of Problem Field */

        $form['submitted']['dops'] = array(
            '#type' => 'fieldset',
            '#title' => t('Fecha del problema'),
            '#weight' => 11,
            '#prefix' => '<div class="spanish_dop">',
            '#suffix' => '</div>',
        );

        $form['submitted']['dops']['dop_months'] = array(
            '#type' => 'select',
            '#default_value' => array('month' => 'Mes'),
            '#options' => array('month' => t('Mes'),
                1 => t('enero'), 2 => t('febrero'), 3 => t('marzo'), 4 => t('abril'), 5 => t('mayo'), 6 => t('junio'), 7 => t('julio'), 8 => t('agosto'), 9 => t('septiembre'), 10 => t('octubre'), 11 => t('noviembre'), 12 => t('diciembre'),
            ),
            '#description' => t('Select month.'),
            '#required' => true,
        );

        /* for 31 days */
        $form['submitted']['dops']['sdop_day_31'] = array(
            '#type' => 'select',
            '#default_value' => array('day' => 'Día'),
            '#options' => array('day' => t('Día'), 1 => t('1'), 2 => t('2'), 3 => t('3'), 4 => t('4'), 5 => t('5'), 6 => t('6'), 7 => t('7'), 8 => t('8'), 9 => t('9'), 10 => t('10'), 11 => t('11'), 12 => t('12'),
                13 => t('13'), 14 => t('14'), 15 => t('15'), 16 => t('16'), 17 => t('17'), 18 => t('18'), 19 => t('19'), 20 => t('20'), 21 => t('21'), 22 => t('22'), 23 => t('23'), 24 => t('24'),
                25 => t('25'), 26 => t('26'), 27 => t('27'), 28 => t('28'), 29 => t('29'), 30 => t('30'), 31 => t('31')),
            '#description' => t("Thirty-One Days."),
            '#required' => true,
        );

        $form['submitted']['dops']['dop_years'] = array(
            '#type' => 'select',
            '#default_value' => array('year' => 'Año'),
            '#options' => array('year' => t('Año'), 1 => t('2013'), 2 => t('2012'), 3 => t('2011'), 4 => t('2010'), 5 => t('2009'), 6 => t('2008'), 7 => t('2007'), 8 => t('2006'),
                9 => t('2005'), 10 => t('2004'), 11 => t('2003'), 12 => t('2002'), 13 => t('2001'), 14 => t('2000'), 15 => t('1999'), 16 => t('1998'), 17 => t('1997'),
                18 => t('1996'), 19 => t('1995'), 20 => t('1994'), 21 => t('1993'), 22 => t('1992'), 23 => t('1991'), 24 => t('1990'), 25 => t('1989'), 26 => t('1988'),
                27 => t('1987'), 28 => t('1986'), 29 => t('1985'), 30 => t('1984'), 31 => t('1983'), 32 => t('1982'), 33 => t('1981'), 34 => t('1980'), 35 => t('1979'), 36 => t('1978'), 37 => t('1977'), 38 => t('1975'),
                39 => t('1974'), 40 => t('1973'), 41 => t('1972'), 42 => t('1971'), 43 => t('1970'), 44 => t('1969'), 45 => t('1968'), 46 => t('1967'), 47 => t('1966'),
                48 => t('1965'), 49 => t('1964'), 50 => t('1963'), 51 => t('1962'), 52 => t('1961'), 53 => t('1960'), 54 => t('1959'), 55 => t('1958'), 56 => t('1957'),
                57 => t('1956'), 58 => t('1955'), 59 => t('1954'), 60 => t('1953'), 61 => t('1952'), 60 => t('1951'), 61 => t('1950'),
            ),
            '#description' => t('Select year.'),
            '#required' => true,
        );

        return $form;
        break;
 }
}
2

This is because the webform module doesn't know anything about your fields so it doesn't have anywhere in the database to save the values to.

For the webform module to save the fields the easiest way is to create the fields via the webform UI, then use form alter to change the widget, or do other things to make the fields like you need them to be.

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.