Skip to content

Instantly share code, notes, and snippets.

@mraaroncruz
Created December 3, 2010 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mraaroncruz/727363 to your computer and use it in GitHub Desktop.
Save mraaroncruz/727363 to your computer and use it in GitHub Desktop.
i want my widget!
<?php
**
* Implementation of hook_form();
*/
// THIS CODE DOESN'T WORK!!! well, i mean, it works, but id doesn't do what it is supposed to do...
function community_form(&$node, $form_state) {
$type = node_get_types('type', $node);
// We need to define form elements for the node's title and body.
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Name of Clothing Item From Picture'),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5
);
// Clothing Image
$form['image'] = array(
'#type' => 'fieldset',
'#title' => t('Customer Image')
);
$form['image']['community_image_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
'#size' => 48,
'#default_value' => $edit['community_image_upload'],
'#description' => t(
'Maximum dimensions are %dimensions and the maximum size is %size kB.',
array(
'%dimensions' => '250x250',
'%size' => '30'
)
)
);
// Here it is, i also tried without the ['image']['community_image_upload'] part... no luck
$form['image']['community_image_upload']['preview']['#value'] = theme('imagefield_widget_preview',$form['#value']);
$form['#validate'][] = 'community_form_validate';
$form['#attributes']['enctype'] = 'multipart/form-data';
// NOTE in node_example there is some addition code here not needed for this simple node-type
return $form;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment