You are here

function paragraphs_admin_bundle_form_validate in Paragraphs 7

Form validation handler for paragraphs_admin_bundle_form().

Parameters

array $form: The form structure array.

array $form_state: An associative array containing the current state of the form.

See also

paragraphs_admin_bundle_form_submit()

File

./paragraphs.admin.inc, line 190
Admin functions for the paragraphs module.

Code

function paragraphs_admin_bundle_form_validate(array $form, array &$form_state) {
  $bundle = new stdClass();
  $bundle->name = trim($form_state['values']['name']);
  if (!$form_state['values']['locked']) {
    $bundle->bundle = trim($form_state['values']['bundle']);

    // 'theme' conflicts with theme_node_form().
    // '0' is invalid, since elsewhere we check it using empty().
    if (in_array($bundle->bundle, array(
      '0',
      'theme',
    ))) {
      form_set_error('type', t("Invalid machine-readable name. Enter a name other than %invalid.", array(
        '%invalid' => $bundle->bundle,
      )));
    }
  }
}