I need to manually render a number field in Drupal 7 on a custom form. I have created the following field definition:
$form['num_seats'] = array(
'#type' => 'textfield',
'#title' => t('Number of Seats'),
'#required' => TRUE,
'#number_type' => 'decimal',
'#field_name' => 'num_seats',
'#element_validate' => array ('number_field_widget_validate'),
'#field_parents' => array(),
'#language' => $language->language,
'#field_prefix' => '$',
'#size' => 14,
'#maxlength' => 12,
'#default_value' => $location ? $location['num_seats'] : $node->field_workshop_num_seats[$node->language][0]['value'],
);
However submitting the form produces an error of the form: "preg_replace() [function.preg-replace]: Compilation failed: range out of order in character class at offset 14 in number_field_widget_validate() (line 391 "
If I use 'integer' instead of 'decimal' for 'number_type', it works fine. I checked Number module's code and could see this is bcause of regex not being created correctly from field definition.
So my question is how can I manually render Fields outside of regular Drupal entity_type context (i.e. outside node/user etc. forms) in a custom form whose submission gets stored to a custom table.