Hello everybody,
I am new to drupal and trying to develop an own form element type via hook_elements. I want to attach a pair of "Title" / "Text" information to the form delivered by the image module to add some more information to images.
My code looks like this:
/* extending the form of 'image' with a pair of 'Title/Text' */
function album_form_alter($form_id,&$form) {
if($form_id == 'image_node_form') {
$form['grussbildinfo']['titelundnachricht'] = array(
'#type' => 'titelundnachricht',
);
}
}
/* defining a custom element type 'titelundnachricht' for pairs of title/text, who will be attachted to images */
function album_elements() {
$type['titelundnachricht'] = array(
'#grussbildtitel' => '',
'#grussnachricht' => '',
);
return $type;
}
/* the theme details for rendering the Title/Text pair */
function theme_titelundnachricht($element) {
$result .= ' ' . $element->grussbildtitel . '';
$result .= ' ' . $element->grussnachricht . '';
return $result;
}
/* hooking into when an image is written: Adding the 'Title/Text' info to its table, too */