function search_by_page_form in Search by Page 8
Same name and namespace in other branches
- 6 search_by_page.module \search_by_page_form()
- 7 search_by_page.module \search_by_page_form()
Returns a Forms API array for the search by pages form.
See also
2 string references to 'search_by_page_form'
- search_by_page_block_view in ./
search_by_page.module - Implements hook_block_view().
- _search_by_page_view in ./
search_by_page.module - Returns a ready-to-render search form and/or results page.
File
- ./
search_by_page.module, line 948 - Main module file for Drupal module Search by Page.
Code
function search_by_page_form($form, &$form_state, $environment, $keys = '', $is_block = TRUE) {
$form['#action'] = url(search_by_page_setting_get('page_path', $environment, 'search_pages'));
$form['#attributes'] = [
'class' => 'search-by-page-form',
];
$form['#method'] = 'post';
$fieldlabel = search_by_page_setting_get('field_label', $environment, t('Search for'));
$buttonlabel = search_by_page_setting_get('button_label', $environment, t('Search'));
if (\Drupal::moduleHandler()
->moduleExists('i18n_string')) {
$fieldlabel = i18n_string_translate('search_by_page:search_form:field_label' . $environment, $fieldlabel);
$buttonlabel = i18n_string_translate('search_by_page:search_form:button_label' . $environment, $buttonlabel);
}
$form['keys'] = [
'#type' => 'textfield',
'#title' => $fieldlabel,
'#default_value' => $keys,
'#size' => 30,
'#maxlength' => 255,
];
$form['environment'] = [
'#type' => 'value',
'#value' => $environment,
];
$form['is_block'] = [
'#type' => 'value',
'#value' => $is_block,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $buttonlabel,
];
return $form;
}