Commerce_price in custom form
Hello,
I have been unsuccessfully trying to add a commerce_price field to a custom form with attempts like this one:
$form['myprice'] = array(
'#type' => 'commerce_price',
'#title' => t('price'),
'#description' => t('enter price.'),
'#default_value' => 5.0,
'#required'=>true,
);
The alternative which is to add a decimal textfield and a currency select field is something I would like to avoid.
Searching the web and commerce code for something similar didn't get me anywhere. Being a drupal noob looking at the code in the commerce_price module did not help me get a clearer view on how to achieve this. All I can say is that it seems to me that since the price field implements all the custom fields hooks it should be usable in forms (but I am not even sure that this intuitive belief is true. For all I know using fields in forms might not be the same as declaring them for fieldable entities)
Many thanks in advance for any help or advice on the topic.
Vitch
[edit]> the answer is that it is not feasible. check below comment for mode details.
Comments
Figured it out
In order to be able to use a field with forms hook_element_info and associated functions need to be implemented. They are currently not implemented in the price module. So the answer to my previous question is that it is currently not feasible.
Would it be possible to turn this entry into a feature request to have the price module implement the element_info hook?
I also need this for a custom
I also need this for a custom product creation wizard.