function afb_new_block_create_form in Advanced Form Block 7
Displays the form enabling the creation of new blocks.
1 string reference to 'afb_new_block_create_form'
- afb_admin_page in ./
afb.module - Returns the page containing existing block list with block creation form.
File
- ./
afb.module, line 106 - Allows administrators to create blockd of node add/edit forms.
Code
function afb_new_block_create_form($form, $form_state) {
$form = array();
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title of the Block'),
'#description' => t('Enter the Desired title'),
'#size' => 60,
'#required' => TRUE,
'#default' => empty($form_state['values']['title']) ? NULL : $form_state['values']['title'],
);
$form['block_type'] = array(
'#type' => 'select',
'#title' => t('Type of the Block'),
'#description' => t('Node Add or Node edit type block'),
'#options' => drupal_map_assoc(array(
t('Add'),
t('Edit'),
)),
'#default' => empty($form_state['values']['block_type']) ? 'Add' : $form_state['values']['block_type'],
'#required' => TRUE,
'#ajax' => array(
'wrapper' => 'input-fields',
'callback' => 'afb_create_block_ajax_handler',
),
);
$form['input_fields'] = array(
'#type' => 'container',
'#prefix' => '<div id="input-fields">',
'#suffix' => '</div>',
);
if (isset($form_state['values']['block_type']) && $form_state['values']['block_type'] === 'Add') {
$node_type_options = node_type_get_types();
foreach ($node_type_options as $key => $val) {
$types[] = $key;
}
$form['input_fields']['content_type'] = array(
'#type' => 'select',
'#title' => t('Content type'),
'#description' => t('Node Add or Node edit Content type'),
'#options' => drupal_map_assoc($types),
'#default' => empty($form_state['values']['content_type']) ? NULL : $form_state['values']['content_type'],
'#required' => TRUE,
);
}
if (isset($form_state['values']['block_type']) && $form_state['values']['block_type'] === 'Edit') {
$form['input_fields']['nid'] = array(
'#type' => 'textfield',
'#title' => t('Name of the referanced node'),
'#autocomplete_path' => 'autocomplete/advanced-form-block',
'#description' => t('Node Add or Node edit type block'),
'#default' => empty($form_state['values']['nid']) ? NULL : $form_state['values']['nid'],
'#required' => TRUE,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Create'),
'#submit' => array(
'afb_new_block_create_form_submit',
),
);
return $form;
}