You are here

function afb_existing_blocks_display_form in Advanced Form Block 7

Displays the form listing existing created blocks in a tableselect fomat.

1 string reference to 'afb_existing_blocks_display_form'
afb_admin_page in ./afb.module
Returns the page containing existing block list with block creation form.

File

./afb.module, line 50
Allows administrators to create blockd of node add/edit forms.

Code

function afb_existing_blocks_display_form($form, $form_state) {
  $form = array();
  $result = db_select('afb_blocks_data', 'n')
    ->fields('n', array(
    'delta',
    'title',
    'form_type',
    'content_type',
    'nid',
  ))
    ->execute();
  $count = $result
    ->rowCount();

  // Save the query to matches.
  foreach ($result as $row) {
    $entries[] = array(
      'delta' => $row->delta,
      'title' => check_plain($row->title),
      'form_type' => check_plain($row->form_type),
      'content_type' => check_plain($row->content_type),
      'nid' => $row->nid,
    );
  }
  $header = array(
    'title' => t('title'),
    'form_type' => t('form type'),
    'content_type' => t('content type'),
    'nid' => t('nid'),
  );
  $options = array();
  if (!empty($entries)) {
    foreach ($entries as $entry) {
      $options[$entry['delta']] = array(
        'title' => $entry['title'],
        'form_type' => $entry['form_type'],
        'content_type' => $entry['content_type'],
        'nid' => $entry['nid'],
      );
    }
  }
  $form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#empty' => t('No form blocks found'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Delete Selected'),
    '#submit' => array(
      'afb_existing_blocks_display_form_submit',
    ),
  );
  return $form;
}