By jdlilly on
I've got my first module working now.
I want the user to enter a number in a form field. The only field I see to use is form_textfield. But I don't want to save the value as a string, I want to save it as an int.
If I do this in the hook_form:
$output .= form_textfield(t('Quantity'), 'quantity', $node->quantity, 60, 128, NULL, NULL, TRUE);
I think it expects 'quantity' to be a column of type string.
So do I have to post-process the user-entered string to convert it to an int? Where and how would I do that? Or is there a form field that will return a numeric value?
Thanks.
-John
Comments
hook_validate
Use hook_validate to verify use input. You should do this anyway to check if everything required was filled in.
--
If you have a problem, please search before posting a question.