You are here

function recipe_field_formatter_settings_form in Recipe 7.2

Implements hook_field_formatter_settings_form().

File

./recipe.module, line 625
Contains functions for Recipe node CRUD and display.

Code

function recipe_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $element = array();

  // Create the recipe ingredient formatter settings form.
  if ($display['type'] == 'recipe_ingredient_default') {
    $element['fraction_format'] = array(
      '#type' => 'textfield',
      '#title' => t('Fractions display string'),
      '#default_value' => $settings['fraction_format'],
      '#size' => 35,
      '#maxlength' => 255,
      '#description' => t('How fractions should be displayed. Leave blank to display as decimals.<br />Each incidence of %d will be replaced by the whole number, the numerator, and the denominator in that order.<br />Anything between curly braces will not be displayed when the whole number is equal to 0.<br />Recommended settings are "{%d }%d&amp;frasl;%d" or "{%d }&lt;sup&gt;%d&lt;/sup&gt;/&lt;sub&gt;%d&lt;/sub&gt;"'),
    );
    $element['unit_abbreviation'] = array(
      '#type' => 'radios',
      '#title' => t('Ingredient unit display'),
      '#default_value' => $settings['unit_abbreviation'],
      '#options' => array(
        t('Abbreviation'),
        t('Full name'),
      ),
      '#description' => t('Display ingredient units like Tbsp or Tablespoon.'),
      '#required' => TRUE,
    );
  }
  return $element;
}