1 block.text.inc BlockText::form(&$form, &$form_state)

Builds the block's configuration form.

Overrides Block::form

File

core/modules/layout/includes/block.text.inc, line 53

Class

BlockText
BlockText extends Block

Code

function form(&$form, &$form_state) {
  parent::form($form, $form_state);

  // Hide the title display, as custom text blocks don't have "default" title
  // from which they would inherit, so it's either a custom title or no title.
  $form['title_display']['title_display']['#access'] = FALSE;

  $form['#attached']['js'][] = backdrop_get_path('module', 'layout') . '/js/layout.admin.js';

  $form['title_display']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Display title'),
    '#default_value' => $this->settings['title'],
    '#maxlength' => 255,
  );
  $form['content'] = array(
    '#type' => 'text_format',
    '#title' => t('Block content'),
    '#default_value' => $this->settings['content'],
    '#format' => $this->settings['format'],
    '#editor_uploads' => TRUE,
    '#rows' => 5,
  );

  if (module_exists('block')) {
    $form['convert'] = array(
      '#weight' => 2,
      '#parents' => array(),
    );
    $form['convert']['reusable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Make this block reusable'),
      '#description' => t('If enabled, this block will be made reusable across different layouts and be listed in on the !block_link page.', array('!block_link' => l(t('Custom blocks'), 'admin/structure/block'))),
      '#weight' => 1,
    );
    // Add a notice for translation.
    if (module_exists('locale')) {
      $form['convert']['reusable']['#description'] .= ' ' . t('Reusable blocks may also be translated.');
    }
  }
  $form['admin_label'] = array(
    '#type' => 'fieldset',
    '#title' => t('Admin label'),
    '#tree' => FALSE,
    '#collapsed' => empty($this->settings['admin_label']),
    '#states' => array(
      'collapsed' => array(
        ':input[name="reusable"]' => array('checked' => FALSE),
      ),
    ),
    '#collapsible' => TRUE,
    '#weight' => 4,
  );
  $form['admin_label']['admin_label'] = array(
    '#type' => 'textfield',
    '#default_value' => isset($this->settings['admin_label']) ? $this->settings['admin_label'] : '',
    '#title' => t('Admin label'),
    '#description' => t('Used to identify the block on layout pages. Required for reusable blocks.'),
    '#maxlength' => 255,
  );
  $form['admin_label']['delta'] = array(
    '#type' => 'machine_name',
    '#title' => t('Internal name'),
    '#maxlength' => 64,
    '#machine_name' => array(
      'source' => array('admin_label', 'admin_label'),
      'exists' => 'block_custom_block_load',
    ),
    '#description' => t('A unique machine-readable name containing letters, numbers, and underscores.'),
    '#weight' => 3,
    '#required' => FALSE,
  );
  $form['admin_label']['admin_description'] = array(
    '#type' => 'textfield',
    '#title' => t('Admin description'),
    '#maxlength' => 128,
    '#default_value' => isset($this->settings['admin_description']) ? $this->settings['admin_description'] : '',
    '#description' => t('This text is used only in administrative interfaces. It will not be shown to site visitors.<br />Allowed HTML tags: @tags', array('@tags' => _filter_xss_display_allowed_tags())),
    '#weight' => 4,
  );
}