function word_link_add_form in Word Link 7
Same name and namespace in other branches
- 8 word_link.admin.inc \word_link_add_form()
- 7.2 word_link.admin.inc \word_link_add_form()
Form builder for add or edit page.
1 string reference to 'word_link_add_form'
- word_link_menu in ./
word_link.module - Implements hook_menu().
File
- ./
word_link.admin.inc, line 298 - Administrative pages for the Word Link module.
Code
function word_link_add_form($form, &$form_state, $id = NULL) {
$form['word_link_add_form'] = array(
'#type' => 'fieldset',
'#title' => t('Add word'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
if (!empty($id)) {
$defaults = word_link_get_link($id);
$form['word_link_add_form']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 15,
'#submit' => array(
'word_link_add_form_delete_submit',
),
);
}
$form['word_link_add_form']['text'] = array(
'#type' => 'textfield',
'#title' => t('Word/Phrase'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('The word or phrase you wish to convert to a link. This field is case sensitive.'),
'#required' => TRUE,
'#default_value' => !empty($defaults[$id]->text) ? $defaults[$id]->text : '',
);
$form['word_link_add_form']['case_sensitive'] = array(
'#type' => 'checkbox',
'#title' => t('Case Sensitivity'),
'#description' => t('By default Word Link are case sensitive. Uncheck this checkbox if you want this particular Word Link to be case insensitive.'),
'#default_value' => isset($defaults[$id]->case_sensitive) ? (int) $defaults[$id]->case_sensitive : 1,
);
$form['word_link_add_form']['url'] = array(
'#type' => 'textfield',
'#title' => t('URL'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('The URL of the page to link to. External links must start with %http or %https and will be open in new window.', array(
'%http' => 'http://',
'%https' => 'https://',
)),
'#required' => TRUE,
'#default_value' => isset($defaults[$id]->url) ? $defaults[$id]->url : '',
);
$form['word_link_add_form']['url_title'] = array(
'#type' => 'textfield',
'#title' => t('URL Title'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('Title for the above URL. It will be embedded in the created link and appear as a tooltip when hovering the mouse over the link.'),
'#default_value' => isset($defaults[$id]->url_title) ? $defaults[$id]->url_title : '',
);
$form['word_link_add_form']['class'] = array(
'#type' => 'textfield',
'#title' => t('Class'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('Use this to add a class for the link. Default value is "word-link".'),
'#default_value' => isset($defaults[$id]->class) ? $defaults[$id]->class : 'word-link',
);
$form['word_link_add_form']['rel'] = array(
'#type' => 'textfield',
'#title' => t('Rel'),
'#size' => 30,
'#maxlength' => 255,
'#description' => t('Use this to add a rel attribute for the link..'),
'#default_value' => isset($defaults[$id]->rel) ? $defaults[$id]->rel : '',
);
$form['word_link_add_form']['visibility'] = array(
'#type' => 'radios',
'#title' => t('Show links on specific pages'),
'#options' => array(
0 => t('All pages except those listed'),
1 => t('Only the listed pages'),
),
'#default_value' => isset($defaults[$id]->visibility) ? $defaults[$id]->visibility : 0,
);
$form['word_link_add_form']['except'] = array(
'#type' => 'textarea',
'#description' => t('Specify pages by using their paths. Enter one path per line. E.g. node/1.'),
'#default_value' => isset($defaults[$id]->except) ? $defaults[$id]->except : '',
);
$form['word_link_add_form']['id'] = array(
'#type' => 'hidden',
'#value' => !empty($id) ? $id : NULL,
);
$form['word_link_add_form']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 15,
'#submit' => array(
'word_link_add_form_save_submit',
),
);
return $form;
}