function _link_widget_form in Link 5
Helper function renders the link widget in both single and multiple value cases.
2 calls to _link_widget_form()
- link_widget in ./
link.module - Implementation of hook_widget().
- link_widget_js in ./
link.module
File
- ./
link.module, line 402 - Defines simple link field types.
Code
function _link_widget_form(&$form_item, $field, $item, $delta = 0) {
$form_item = array(
'#tree' => TRUE,
'#theme' => 'link_widget_form_row',
);
$default_url = "";
if (isset($field['widget']['default_value'][$delta]['url'])) {
$default_url = $field['widget']['default_value'][$delta]['url'];
}
$form_item['url'] = array(
'#type' => 'textfield',
'#maxlength' => '255',
'#title' => $delta == 0 ? t('URL') : NULL,
'#default_value' => $item['url'] ? $item['url'] : $default_url,
'#required' => $delta == 0 ? $field['required'] && empty($field['url']) : FALSE,
);
if ($field['title'] != 'value' && $field['title'] != 'none') {
$default_title = "";
if (isset($field['widget']['default_value'][$delta]['title'])) {
$default_title = $field['widget']['default_value'][$delta]['title'];
}
$form_item['title'] = array(
'#type' => 'textfield',
'#maxlength' => '255',
'#title' => $delta == 0 ? t('Title') : NULL,
'#default_value' => $item['title'] ? $item['title'] : $default_title,
'#required' => $delta == 0 && $field['title'] == 'required' ? $field['required'] : FALSE,
);
}
if (!empty($field['attributes']['target']) && $field['attributes']['target'] == 'user') {
$form_item['attributes']['target'] = array(
'#type' => 'checkbox',
'#title' => t('Open URL in a New Window'),
'#default_value' => $item['attributes']['target'],
'#return_value' => "_blank",
);
}
}