function recipe_import_form in Recipe 7.2
Same name and namespace in other branches
- 6 recipe.module \recipe_import_form()
- 7 recipe.module \recipe_import_form()
Page callback: Constructs a form for importing a single recipe.
See also
recipe_import_form_build_preview()
1 string reference to 'recipe_import_form'
- recipe_menu in ./
recipe.module - Implements hook_menu().
File
- ./
recipe.admin.inc, line 137 - Contains admin page callbacks, form validation, and form submission handlers.
Code
function recipe_import_form($form, &$form_state) {
$formats = module_invoke_all('recipeio', 'import_single');
$options = array();
foreach ($formats as $format) {
$options[$format['callback']] = $format['format_name'];
}
// Some special stuff when previewing a node.
if (isset($form_state['node_preview'])) {
$form['#prefix'] = $form_state['node_preview'];
}
$form['recipe_format'] = array(
'#type' => 'select',
'#title' => t('Recipe format'),
'#options' => $options,
'#default_value' => !empty($form_state['values']['recipe_format']) ? $form_state['values']['recipe_format'] : '',
'#size' => 1,
'#description' => t('The recipe input format.'),
);
$form['recipe_import_text'] = array(
'#type' => 'textarea',
'#title' => t('Paste import data here'),
'#default_value' => !empty($form_state['values']['recipe_import_text']) ? $form_state['values']['recipe_import_text'] : '',
'#cols' => 55,
'#rows' => 8,
'#required' => TRUE,
'#description' => t('Use 1 blank line between sections: Description, Ingredients, Instructions, Notes. Always use preview first to avoid unintended consequences.'),
'#attributes' => array(
'class' => array(
'recipe-import-text',
),
),
);
$form['buttons']['preview'] = array(
'#type' => 'submit',
'#value' => t('Preview'),
'#weight' => 1,
'#submit' => array(
'recipe_import_form_build_preview',
),
);
$form['buttons']['import'] = array(
'#type' => 'submit',
'#value' => t('Import'),
'#weight' => 2,
'#submit' => array(
'recipe_import_form_submit',
),
);
return $form;
}