I am trying to write a custom field, which basically contains the following 3 fields:
I tried to reuse the link module to implement the 'Link' field. But I got a lot problem in storing the input data, configuration, and validation. Could anyone help me on this, thanks.
This is what i write in the hook_field_widget_form():
function my_custom_fields_field_widget_form(&$form, &$form_state, $field, $instance,
$langcode, $items, $delta, $element) {
$widget = $element;
$widget['#delta'] = $delta;
switch ($instance['widget']['type']) {
case 'examples_basic':
$widget += array(
'#type' => 'fieldset',
'#element_validate' => array('my_custom_fields_lever_examples_basic_validate'),
'#delta' => $delta,
);
$widget['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : null,
);
$widget['desc'] = array(
'#type' => 'textarea',
'#title' => t('Descrption'),
'#default_value' => isset($items[$delta]['desc']) ? $items[$delta]['desc'] : null,
);
$widget['url'] = array(
'#type' => 'link_field',
'#title' => t('Link'),
);
}
$element += $widget;
return $element;
}