function multiblock_add_form in MultiBlock 7
Same name and namespace in other branches
- 5 multiblock.module \multiblock_add_form()
- 6 multiblock.module \multiblock_add_form()
"Add Instance" form.
1 string reference to 'multiblock_add_form'
- multiblock_general in ./
multiblock.module - Page callback for the "Manage Block Instances page".
File
- ./
multiblock.module, line 195 - Enhances the block API, as provided by D7 Core.
Code
function multiblock_add_form($form, &$form_state, $blocks, $update = NULL) {
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Instance Title'),
'#maxlength' => 256,
'#required' => TRUE,
'#default_value' => isset($update->title) ? $update->title : NULL,
);
if ($update) {
$form['instance'] = array(
'#type' => 'value',
'#value' => $update->delta,
);
}
else {
// Turn $blocks into form options of block types.
// Remember we need the module and delta to be able to tell what kind of
// blocks we're talking about.
$options = array();
foreach ($blocks as $block) {
// Don't include multiblock module blocks in the list.
if ($block['module'] != 'multiblock') {
$options[$block['module'] . '***MB***' . $block['delta']] = $block['info'];
}
}
$form['block'] = array(
'#type' => 'select',
'#title' => t('Block type'),
'#options' => $options,
'#required' => TRUE,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}