By eyedol on
Newbie here, as learning process, i'm creating a module that collect data from the user then insert them into the db, but i can't figure out how to get the content of the form varible . This is the function that displays the form to the user
/*** This is a callback funtion actually ****/
function display_form()
$index_lang = index_lang();
$output = '<h2>'.t('Add New Entry').'</h2>';
$form = form_textfield( t('Language'),'dictname',
'',50,50,'Enter new language',
$required = TRUE
);
$form .= form_select( t('Index language'),'indexlang',
key($index_lang), $index_lang,
t( 'Select the index language of the
new language')
);
$form .= form_radios( t('Status'), 'status',
'',array('status' => t('On'),t('Off'))
);
$form .= form_submit( t( 'Add Entry' ) );
$output .= form( $form );
print theme( 'page', $output );
}
Please help on how to get the content of the form element when the user clicks on the submit button.
Comments
Look for post data before displaying the form
You need to add something like the following before the begining of function code.
Getting actual select value
please how do i get the actual value of the select element. i realise i get the key of it. Thanks.
Once you have $edit
Once you have $edit you can get the value like
ok thanks for the help, what
ok thanks for the help, what i actually want from the select element is the is string value of the select element not the key value element. To explain further,
the options for the select element are
English
Spanish
Arabic
but when i insert the value into the db is numbers. Base on what i select i get its number. say if i select Spanish i get 1 stored in the db. i want to store what i select into the db so in this case Spanish should be stored.
This might help
Make sure the line "$index_lang = index_lang();" is before the 'if' checking $edit and $op. Then after you get the value
should get you the string value.
I tried that but it gave me
I tried that but it gave me empty string
How about trying this
In the code right after you get the value try this
This will show the value plus the array members when you submit. I would expect the value to be one of the keys in $index_lang but it sounds like it is not which is unexpected.
If the output does not help and you want you can post it here.
This is what i got the
This is what i got
the output:
Manage to solve it
I manage to solve it by using the selected key to determine the actuall value. the code is this
Well that does not make sense
A value of 'yes' does not make sense with the code you have shown. Is it possible for you to share a url to a page with the form (if you don't want it public you could always email me through my contact tab). Also seeing the latest complete copy of the function would be useful.