diff --git a/src/Form/Pagingform.php b/src/Form/Pagingform.php index 6566686..0d3e4b2 100644 --- a/src/Form/Pagingform.php +++ b/src/Form/Pagingform.php @@ -22,11 +22,35 @@ class Pagingform extends FormBase { */ public function buildForm(array $form, FormStateInterface $form_state) { $contentTypes = \Drupal::service('entity.manager')->getStorage('node_type')->loadMultiple(); - - - // Set the id of the top-level form tag. $form['#id'] = 'contentpager'; + $form['paging_general'] = array( + '#type' => 'fieldset', + '#title' => t('General paging settings'), + '#collapsible' => FALSE, + ); + + // Paging separator string. + // @TODO will need an upgrade path. + $form['paging_general']['paging_separator'] = array( + '#type' => 'textfield', + '#title' => t('Page separator string'), + '#size' => 20, + '#maxlength' => 255, + '#description' => t('Use an HTML tag that will render reasonably when + paging is not enabled, such as %pagebreak or %hr.'), + ); + + $form['paging_general']['paging_pager_count'] = array( + '#type' => 'radios', + '#title' => t('Number of Pagers on each page'), + '#options' => array( + 'one' => t('One'), + 'two' => t('Two'), + ), + '#attributes' => array('class' => array('paging-pager')), + ); + $contentTypesList = []; foreach ($contentTypes as $contentType) { @@ -48,7 +72,6 @@ class Pagingform extends FormBase { '#attributes' => array('class' => array('paging-left')), ); - // Paging toggle checkbox. $form[$content_type]['paging_config']['paging_left']['paging_enabled_' . $content_type] = array( '#type' => 'checkbox', @@ -91,7 +114,6 @@ class Pagingform extends FormBase { ); - $form[$content_type]['paging_config']['paging_right']['paging_automatic_method_' . $content_type] = array( '#type' => 'radios', '#title' => t('Automatic paging method'), @@ -99,18 +121,12 @@ class Pagingform extends FormBase { 'disabled' => t('Disabled'), 'chars' => t('Limit by characters (recommended)'), 'words' => t('Limit by words')), - '#description' => t('Method for automatic paging (ignored where paging - separator string is used).'), - + separator string is used).'), '#attributes' => array('class' => array('paging-method')), ); - - - // Get the length options. - // @TODO: Do we really need 750? $char_len_options = array(-1 => 750) + range(500, 7500, 500); $word_len = range(100, 1000, 50); asort($char_len_options); @@ -121,13 +137,11 @@ class Pagingform extends FormBase { '#title' => t('Length of each page'), '#options' => $char_len_options, '#field_suffix' => t('characters'), - '#description' => '
' . t('Number of characters to display per page.'), - //'#default_value' => variable_get('paging_automatic_chars_' . $content_type, 4000), '#prefix' => '
', '#suffix' => '
', '#states' => array( - 'visible' => array(// action to take. + 'visible' => array( ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'chars'), ), @@ -140,13 +154,11 @@ class Pagingform extends FormBase { '#title' => t('Length of orphans'), '#size' => 6, '#field_suffix' => t('characters'), - '#description' => '
' . t('Number of characters to consider as an orphan.'), - // '#default_value' => variable_get('paging_automatic_chars_orphan_' . $content_type, 100), '#prefix' => '
', '#suffix' => '
', '#states' => array( - 'visible' => array(// action to take. + 'visible' => array( ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'chars'), ), @@ -159,13 +171,11 @@ class Pagingform extends FormBase { '#title' => t('Length of each page'), '#options' => $word_len, '#field_suffix' => t('words'), - '#description' => '
' . t('Number of words to display per page.'), - // '#default_value' => variable_get('paging_automatic_words_' . $content_type, 400), '#prefix' => '
', '#suffix' => '
', '#states' => array( - 'visible' => array(// action to take. + 'visible' => array( ':input[name="paging_enabled_' . $content_type . '"]' => array('checked' => TRUE), ':input[name="paging_automatic_method_' . $content_type . '"]' => array('value' => 'words'), ), @@ -190,11 +200,6 @@ class Pagingform extends FormBase { ), ), ); - - - - - } $form['submit'] = array( @@ -203,8 +208,6 @@ class Pagingform extends FormBase { ); - - return $form; }