function ctools_custom_content_type_edit_form_validate

The validate form to ensure the custom content data is okay.

File

plugins/content_types/custom/custom.inc, line 414

Code

function ctools_custom_content_type_edit_form_validate(&$form, &$form_state) {
    if ($form_state['settings']['custom_type'] != 'fixed' && !empty($form_state['values']['reusable'])) {
        if (empty($form_state['values']['name'])) {
            form_error($form['name'], t('Name is required.'));
        }
        // Check for string identifier sanity.
        if (!preg_match('!^[a-z0-9_]+$!', $form_state['values']['name'])) {
            form_error($form['name'], t('The name can only consist of lowercase letters, underscores, and numbers.'));
            return;
        }
        if (!module_exists('ctools_custom_content')) {
            return;
        }
        // Check for name collision.
        if ($form_state['values']['name'] == 'custom' || ctools_export_crud_load('ctools_custom_content', $form_state['values']['name'])) {
            form_error($form['name'], t('Content with this name already exists. Please choose another name or delete the existing item before creating a new one.'));
        }
    }
}