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 49

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['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['convert']['label'] = array(
      '#type' => 'textfield',
      '#title' => t('Admin label'),
      '#maxlength' => 64,
      '#description' => t('This text is used only in administrative interfaces. It will not be shown to site visitors.'),
      '#weight' => 2,
      '#states' => array(
        'visible' => array(
          ':input[name="reusable"]' => array('checked' => TRUE),
        ),
      ),
    );
    $form['convert']['description'] = array(
      '#type' => 'textfield',
      '#title' => t('Admin description'),
      '#maxlength' => 128,
      '#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,
      '#states' => array(
        'visible' => array(
          ':input[name="reusable"]' => array('checked' => TRUE),
        ),
      ),
    );
    $form['convert']['delta'] = array(
      '#type' => 'machine_name',
      '#title' => t('Internal name'),
      '#maxlength' => 64,
      '#machine_name' => array(
        'source' => array('convert', 'label'),
        'exists' => 'block_custom_block_load',
      ),
      '#description' => t('A unique machine-readable name containing letters, numbers, and underscores.'),
      '#weight' => 3,
      '#required' => FALSE,
    );
  }
}