function msnf_field_overview_validate in Multistep Nodeform 7
Validate handler for the overview screens.
Parameters
array $form: The complete form.
array $form_state: The state of the form.
1 string reference to 'msnf_field_overview_validate'
- msnf_field_ui_overview_form_alter in includes/
msnf.field_ui.inc - Function to alter the fields overview screen.
File
- includes/
msnf.field_ui.inc, line 504 - msnf.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).
Code
function msnf_field_overview_validate($form, &$form_state) {
$form_values = $form_state['values']['fields'];
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$step = $form_values['_add_new_step'];
// Validate if any information was provided in the 'add new step' row.
if (array_filter(array(
$step['label'],
$step['step_name'],
))) {
// Missing label.
if (!$step['label']) {
form_set_error('fields][_add_new_step][label', t('Add new step: you need to provide a label.'));
}
// Missing step name.
if (!$step['step_name']) {
form_set_error('fields][_add_new_step][step_name', t('Add new step: you need to provide a step name.'));
}
else {
$step_name = $step['step_name'];
// Add the 'step_' prefix.
if (drupal_substr($step_name, 0, 5) != 'step_') {
$step_name = 'step_' . $step_name;
form_set_value($form['fields']['_add_new_step']['step_name'], $step_name, $form_state);
}
// Invalid step name.
if (!preg_match('!^step_[a-z0-9_]+$!', $step_name)) {
form_set_error('fields][_add_new_step][step_name', t('Add new step: the step name %step_name is invalid. The name must include only lowercase unaccentuated letters, numbers, and underscores.', array(
'%step_name' => $step_name,
)));
}
if (drupal_strlen($step_name) > 32) {
// This should never happen as we limit the input to 27 characters.
form_set_error('fields][_add_new_step][step_name', t("Add new step: the step name %step_name is too long. The name is limited to 32 characters, including the 'step_' prefix.", array(
'%step_name' => $step_name,
)));
}
}
}
}