function formdefaults_edit in Form Defaults 6
Same name and namespace in other branches
- 5.3 formdefaults.module \formdefaults_edit()
- 5 formdefaults.module \formdefaults_edit()
- 5.2 formdefaults.module \formdefaults_edit()
- 6.2 formdefaults.module \formdefaults_edit()
- 7 formdefaults.module \formdefaults_edit()
Form to edit the field title and description.
3 string references to 'formdefaults_edit'
- formdefaults_alterform in ./
formdefaults.module - Alters the form based on the form replacement items passed.
- formdefaults_form_alter in ./
formdefaults.module - implements hook_form_alter
- formdefaults_menu in ./
formdefaults.module - Implements hook_menu.
File
- ./
formdefaults.module, line 223
Code
function formdefaults_edit() {
$form_array = $_SESSION['formdefaults_forms'];
$formid = arg(1);
$fieldname = arg(2);
$originalfields = $form_array[$formid][$fieldname];
$savedform = formdefaults_getform($formid);
$weight_range = range(-50, 50);
$weights = array(
'unset' => 'unset',
);
foreach ($weight_range as $weight) {
$weights[(string) $weight] = (string) $weight;
}
if (is_array($savedform[$fieldname])) {
$formfields = array_merge($originalfields, $savedform[$fieldname]);
}
else {
$formfields = $originalfields;
}
$form['formid'] = array(
'#type' => 'hidden',
'#value' => $formid,
);
$form['fieldname'] = array(
'#type' => 'hidden',
'#value' => $fieldname,
);
$form['type'] = array(
'#type' => 'hidden',
'#title' => 'Field Type',
'#value' => $originalfields['type'],
);
$form['warning'] = array(
'#type' => 'markup',
'#value' => 'Some text to edit',
);
$form['hide_it'] = array(
'#type' => 'checkbox',
'#title' => 'Hide this field',
'#description' => 'Checking this box will convert the field to a hidden field.' . ' Fields will not actually be hidden while the form editor is enabled. ' . '(Otherwise you wouldn\'t be able to unhide them). ',
'#default_value' => $formfields['hide_it'],
);
if ($originalfields['type'] == 'markup') {
$form['value'] = array(
'#type' => 'textarea',
'#title' => 'Text or markup',
'#rows' => 30,
'#cols' => 80,
'#default_value' => $formfields['value'],
);
$form['format'] = filter_form($formfields['format']);
$form['value_original'] = array(
'#type' => item,
'#title' => 'Original value',
'#value' => $originalfields['value'],
);
}
else {
$form['title'] = array(
'#type' => 'textfield',
'#title' => 'Field Title',
'#default_value' => $formfields['title'],
);
$form['title_old'] = array(
'#type' => 'item',
'#title' => 'Original Title',
'#value' => $originalfields['title'],
);
$form['description'] = array(
'#type' => 'textarea',
'#title' => 'Field Description',
'#default_value' => $formfields['description'],
'#rows' => 30,
'#cols' => 80,
);
$form['description_old'] = array(
'#type' => 'item',
'#title' => 'Original Description',
'#value' => $originalfields['description'],
);
}
$form['weight'] = array(
'#type' => 'select',
'#title' => 'Weight',
'#options' => $weights,
'#default_value' => $formfields['weight'],
'#description' => 'Higher values appear near at the top of the form, lower values at the bottom.',
);
$form['weight_old'] = array(
'#type' => 'item',
'#title' => 'Original Weight',
'#value' => $originalfields['weight'],
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}