function word_link_add_form in Word Link 7.2
Same name and namespace in other branches
- 8 word_link.admin.inc \word_link_add_form()
- 7 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 62 - Administrative pages for the Word Link module.
Code
function word_link_add_form($form, &$form_state, $word = NULL) {
$form['word'] = array(
'#type' => 'fieldset',
'#title' => t('Add word'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
$form['word']['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,
'#autocomplete_path' => 'word-link/ajax/words',
'#default_value' => !empty($word->text) ? $word->text : '',
);
$form['word']['weight'] = array(
'#type' => 'textfield',
'#title' => t('Weight'),
'#size' => 3,
'#maxlength' => 3,
'#description' => t('Weight of the word. Lighter weights are higher up, heavier weights go down.'),
'#required' => TRUE,
'#default_value' => !empty($word->weight) ? $word->weight : 0,
);
$form['word']['case_sensitive'] = array(
'#type' => 'checkbox',
'#title' => t('Case Sensitive'),
'#description' => t('By default Word Link are case sensitive. Uncheck the checkbox if you want this particular Word Link to be case insensitive.'),
'#default_value' => isset($word->case_sensitive) ? (int) $word->case_sensitive : variable_get('word_link_defaults_case_sensitive', 1),
);
$form['word']['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,
'#autocomplete_path' => 'word-link/ajax/urls',
'#default_value' => isset($word->url) ? $word->url : '',
);
$form['word']['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($word->url_title) ? $word->url_title : '',
);
$form['word']['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($word->class) ? $word->class : variable_get('word_link_defaults_class', 'word-link'),
);
$form['word']['rel'] = array(
'#type' => 'textfield',
'#title' => t('Relationship'),
'#size' => 30,
'#maxlength' => 30,
'#description' => t('Use this to add a rel attribute to the link.'),
'#default_value' => isset($word->rel) ? $word->rel : variable_get('word_link_defaults_rel', ''),
);
$form['word']['visibility'] = array(
'#type' => 'radios',
'#title' => t('Show links on specific pages'),
'#options' => array(
t('All pages except those listed'),
t('Only the listed pages'),
),
'#default_value' => isset($word->visibility) ? $word->visibility : 0,
);
$form['word']['except_list'] = array(
'#type' => 'textarea',
'#description' => t('Specify pages by using their paths. Enter one path per line. E.g. node/1.'),
'#default_value' => isset($word->except_list) ? $word->except_list : '',
);
$form['word']['status'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#description' => t('If unchecked this word will not be converted.'),
'#default_value' => isset($word->status) ? (int) $word->status : variable_get('word_link_defaults_status', 1),
);
$form['word']['id'] = array(
'#type' => 'hidden',
'#value' => isset($word->id) ? $word->id : NULL,
);
$form['actions'] = array(
'#type' => 'container',
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 0,
'#submit' => array(
'word_link_add_form_save_submit',
),
);
if (!empty($word)) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 1,
'#submit' => array(
'word_link_add_form_delete_submit',
),
);
}
return $form;
}