You are here

function recipe_yield_form in Recipe 6

Same name and namespace in other branches
  1. 7.2 recipe.module \recipe_yield_form()
  2. 7 recipe.module \recipe_yield_form()
1 string reference to 'recipe_yield_form'
theme_recipe_summary in ./recipe.module

File

./recipe.module, line 1359
recipe.module - share recipes

Code

function recipe_yield_form($form_id, $node) {

  // Don't render the custom yield textbox and submit buttons if disabled or shown in a block.
  if ($node->yield_form_off == 1 || variable_get('recipe_summary_location', 0) == 1 || $node->build_mode == NODE_BUILD_PREVIEW) {
    $form['yield'] = array(
      '#value' => $node->yield,
    );

    // An html space is useful here since we don't have a separate theme function for this form.
    $form['_space'] = array(
      '#value' => ' ',
    );
    $form['yield_unit'] = array(
      '#value' => $node->yield_unit == '' ? t('Servings') : $node->yield_unit,
    );
  }
  else {
    $form['custom_yield'] = array(
      '#type' => 'textfield',
      '#default_value' => $node->yield,
      '#size' => 2,
      '#maxlength' => 4,
    );
    $form['yield_unit'] = array(
      '#value' => $node->yield_unit == '' ? t('Servings') : $node->yield_unit,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Change'),
    );
    $form['reset'] = array(
      '#type' => 'submit',
      '#value' => t('Reset'),
    );
    $form['halve'] = array(
      '#type' => 'submit',
      '#value' => t('Halve'),
    );
    $form['double'] = array(
      '#type' => 'submit',
      '#value' => t('Double'),
    );
  }
  return $form;
}