1 layout.flexible.inc | layout_flexible_template_configure_form($form, &$form_state, LayoutFlexibleTemplate $flexible_template) |
Form to manage adding and removing rows to a flexible template.
Parameters
LayoutFlexibleTemplate $flexible_template: The template configuration being edited.
Related topics
File
- core/
modules/ layout/ layout.flexible.inc, line 114 - Provides configurable (flexible) layout templates.
Code
function layout_flexible_template_configure_form($form, &$form_state, LayoutFlexibleTemplate $flexible_template) {
form_load_include($form_state, 'inc', 'layout', 'layout.admin');
form_load_include($form_state, 'inc', 'layout', 'layout.flexible');
$form['help'] = array(
'#type' => 'help',
'#markup' => t('This page allows you to add or remove rows, and change the order of rows by dragging them up and down. You can also change the number of regions within each row, and adjust the width of each region.'),
);
$messages = array();
$form['messages'] = array(
'#theme' => 'status_messages',
'#messages' => $messages,
'#weight' => -100,
// Prefix/suffix used to identify in AJAX requests.
'#prefix' => '<div id="layout-messages">',
'#suffix' => '</div>',
);
$form_state['flexible_template'] = &$flexible_template;
$flexible_template_name = $flexible_template->name;
$config = array(
'is_new' => TRUE,
'layout_template' => $flexible_template_name,
);
$layout = new Layout($config);
$template = layout_get_layout_template_info($flexible_template_name);
backdrop_set_title($template['title']);
$form_state['flexible_template_name'] = $flexible_template_name;
if (empty($form_state['flexible_template'])) {
return array();
}
$renderer = layout_create_renderer('flexible', $layout);
$form['content'] = array(
'#type' => 'item',
'#id' => 'layout-flexible-content',
);
$form['content']['display'] = array(
'#markup' => $renderer->render(),
);
$form['content']['row_positions'] = array(
// Use 'hidden' instead of 'value' so the JS can access it.
'#type' => 'hidden',
'#default_value' => implode(',', array_keys($flexible_template->rows)),
);
$form['content']['add_row'] = array(
'#type' => 'submit',
'#value' => t('Add row'),
'#attributes' => array('class' => array('layout-flexible-add-row', 'button-secondary')),
'#submit' => array(
'layout_flexible_template_add_row',
),
'#ajax' => array(
'callback' => 'layout_ajax_form_open_dialog',
),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save layout template'),
'#submit' => array(
'layout_flexible_template_configure_form_submit',
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'layout_flexible_template_configure_form_cancel',
),
);
return $form;
}