function paragraphs_admin_bundle_form in Paragraphs 7
Form to create or edit an paragraphs bundle.
Parameters
array $form: The form structure array.
array $form_state: An associative array containing the current state of the form.
object $bundle: The bundle.
Return value
array The form structure array.
2 string references to 'paragraphs_admin_bundle_form'
- PanelizerEntityParagraphsItem::hook_form_alter in plugins/
panelizer/ entity/ PanelizerEntityParagraphsItem.class.php - Implements hook_form_alter().
- paragraphs_menu in ./
paragraphs.module - Implements hook_menu().
File
- ./
paragraphs.admin.inc, line 110 - Admin functions for the paragraphs module.
Code
function paragraphs_admin_bundle_form(array $form, array &$form_state, $bundle = NULL) {
if (!isset($bundle) && !$bundle) {
// This is a new bundle.
$bundle = new stdClass();
$bundle->name = '';
$bundle->bundle = '';
$bundle->label = '';
$bundle->description = '';
$bundle->locked = 0;
}
else {
if (!$bundle) {
drupal_set_message(t('Could not load bundle'), 'error');
drupal_goto('admin/structure/paragraphs');
}
}
$form['#paragraphs_bundle'] = $bundle;
$form['name'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $bundle->name,
'#description' => t('The human-readable name of this bundle. It is recommended that this name begin with a capital letter and contain only letters, numbers, and spaces. This name must be unique.'),
'#required' => TRUE,
'#size' => 30,
);
$form['bundle'] = array(
'#type' => 'machine_name',
'#default_value' => $bundle->bundle,
'#maxlength' => 32,
'#disabled' => $bundle->locked,
'#machine_name' => array(
'exists' => 'paragraphs_bundle_load',
),
'#description' => t('A unique machine-readable name for this paragraph bundle. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['label'] = array(
'#title' => t('Label'),
'#type' => 'textfield',
'#default_value' => $bundle->label,
'#description' => t('The label for this bundle as it will appear to users on edit forms. Defaults to bundle name if left empty.'),
'#size' => 30,
);
$form['description'] = array(
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => $bundle->description,
'#description' => t('Describe this bundle. The text will be displayed on the Paragraphs admin overview page.'),
);
$form['locked'] = array(
'#type' => 'value',
'#value' => $bundle->locked,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Paragraph bundle'),
'#weight' => 40,
);
return $form;
}