1.20.x layout.flexible.inc | layout_flexible_template_edit_row_form($form, &$form_state, LayoutFlexibleTemplate $flexible_template, $original_row, $region_style = NULL) |
Form to add or edit a row on a flexible template.
Parameters
LayoutFlexibleTemplate $flexible_template: The loaded flexible template object.
string $original_row: The row above or below which a new row is being inserted.
string $region_style: The selected region style.
Related topics
File
- modules/
layout/ layout.flexible.inc, line 431 - Provides configurable (flexible) layout templates.
Code
function layout_flexible_template_edit_row_form($form, &$form_state, LayoutFlexibleTemplate $flexible_template, $original_row, $region_style = NULL) {
form_load_include($form_state, 'inc', 'layout', 'layout.flexible');
form_load_include($form_state, 'inc', 'layout', 'layout.admin');
$form_state['flexible_template'] = &$flexible_template;
$flexible_template_name = $flexible_template->name;
$form_state['flexible_template_name'] = $flexible_template_name;
$form_state['original_row'] = $original_row;
$row_data = array();
if ($original_row != 'add') {
if (isset($flexible_template->rows[$original_row]['in_progress'])) {
$row_data = $flexible_template->rows[$original_row]['in_progress'];
}
else {
$row_data = $flexible_template->rows[$original_row];
}
}
$region_style = $region_style ? $region_style : $row_data['contains'];
$form_state['region_style'] = $region_style;
$row_styles = layout_flexible_row_styles();
$selected_style = $row_styles[$region_style]['name'];
$region_count = $row_styles[$region_style]['region_count'];
if ($original_row == 'add') {
backdrop_set_title(t('Add new row'));
}
else {
backdrop_set_title(t('Configure row !original_row', array('!original_row' => $original_row)));
}
$form['region_style'] = array(
'#type' => 'item',
'#title' => t('Selected region widths'),
'#markup' => $selected_style,
);
if ($original_row != 'add') {
$form['change_region_style'] = array(
'#type' => 'submit',
'#value' => t('Change region widths'),
'#attributes' => array('class' => array('layout-link-button')),
'#submit' => array(
'layout_flexible_template_change_region_style',
),
'#ajax' => array(
'callback' => 'layout_ajax_form_open_dialog',
),
);
}
$form['region_names'] = array(
'#type' => 'fieldset',
'#title' => t('Region names'),
'#collapsed' => $original_row != 'add',
'#collapsible' => TRUE,
'#tree' => TRUE,
);
$form_state['last_region_number'] = layout_flexible_template_get_last_region_number($flexible_template);
for ($i = 0; $i < $region_count; $i++) {
$form['region_names']['region_name_' . $i] = array(
'#type' => 'textfield',
'#title' => t('Region') . ' ' . ($i + 1) . ' ' . t('name'),
'#default_value' => !empty($row_data['region_names']['region_name_' . $i]) ? $row_data['region_names']['region_name_' . $i] : t('Region') . ' ' . ($form_state['last_region_number'] + $i + 1),
);
}
$form['region_styles'] = array(
'#type' => 'fieldset',
'#title' => t('Style'),
'#collapsed' => $original_row != 'add',
'#collapsible' => TRUE,
);
$options = array(
'div' => 'DIV',
'nav' => 'NAV',
'aside' => 'ASIDE',
'section' => 'SECTION',
'header' => 'HEADER',
'footer' => 'FOOTER',
'main' => 'MAIN',
);
$form['region_styles']['element'] = array(
'#title' => t('Row wrapper tag'),
'#type' => 'select',
'#options' => $options,
'#default_value' => isset($row_data['element']) ? $row_data['element'] : '',
);
$form['region_styles']['container'] = array(
'#title' => t('Row width behavior'),
'#type' => 'radios',
'#options' => array(
'container' => t('Fixed maximum width'),
'container_fluid' => t('Fluid width'),
'no_container' => t('Full width'),
),
'#default_value' => isset($row_data['container']) ? $row_data['container'] : 'container_fluid',
);
$form['region_styles']['container']['container']['#description'] = t('Adds the <code>container</code> class to the row.');
$form['region_styles']['container']['container_fluid']['#description'] = t('Adds the <code>container-fluid</code> class to the row (no <code>max-width</code>, but <code>padding</code>).');
$form['region_styles']['container']['no_container']['#description'] = t('No container-related classes added to the row (e.g. for Hero blocks).');
$form['region_styles']['row_classes'] = array(
'#title' => t('Additional row classes'),
'#type' => 'textfield',
'#default_value' => isset($row_data['classes']) ? $row_data['classes'] : '',
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#name' => 'submit',
'#value' => t('Save configuration'),
'#attributes' => array('class' => array('layout-title-button')),
'#validate' => array(
'layout_flexible_template_edit_row_validate',
),
'#submit' => array(
'layout_flexible_template_edit_row_form_submit',
),
'#ajax' => array(
'callback' => 'layout_flexible_template_edit_row_ajax',
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#validate' => array(),
'#submit' => array(
'layout_flexible_template_cancel',
),
'#ajax' => array(
'callback' => 'layout_flexible_template_cancel_ajax',
),
);
return $form;
}