You are here

function markup_field_settings in Markup 6

Implements hook_field_settings().

File

./markup.module, line 20
Defines a field type for displaying markup on the node/edit form.

Code

function markup_field_settings($op, $field) {
  switch ($op) {
    case 'form':
      $form = array();
      $form['instructions'] = array(
        '#type' => 'markup',
        '#value' => t('This is a special field. It will output the markup below, unfiltered by the system, on the node/edit form for this content type.'),
        '#weight' => -1,
      );
      $form['markup'] = array(
        '#type' => 'textarea',
        '#title' => t('Markup'),
        '#default_value' => isset($field['markup']) ? $field['markup'] : '',
        '#rows' => 15,
        '#description' => t('The markup to be displayed. Any HTML is legal here, so be careful not to break your page layout.'),
      );
      $form['advanced_options'] = array(
        '#type' => 'fieldset',
        '#title' => t('PHP code'),
        '#collapsible' => TRUE,
        '#collapsed' => empty($field['markup_php']),
      );
      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
        $form['advanced_options']['markup_php'] = array(
          '#type' => 'textarea',
          '#title' => t('Code'),
          '#default_value' => !empty($field['markup_php']) ? $field['markup_php'] : '',
          '#rows' => 8,
          '#description' => t('Advanced usage only: PHP code to replace HTML in the Markup field above. Should include <?php ?> delimiters. You can access the current node object using $node. Use print or echo to output the text to display.'),
        );
      }
      else {
        $form['advanced_options']['markup_php'] = array(
          '#type' => 'item',
          '#title' => t('Code'),
          '#value' => !empty($field['markup_php']) ? '<code>' . check_plain($field['markup_php']) . '</code>' : t('&lt;none&gt;'),
          '#description' => empty($field['markup_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the markup field above.'),
        );
      }
      return $form;
    case 'validate':
      break;
    case 'save':
      return array(
        'markup',
        'markup_php',
      );
    case 'database columns':
      return array();
  }
}