You are here

function picture_admin_import_form_validate in Picture 7

Validate a mapping import.

File

./picture.admin.inc, line 182
Picture - map breakpoints and image styles

Code

function picture_admin_import_form_validate($form, &$form_state) {
  ctools_include('export');
  $code = $form_state['values']['import'];
  $mapping = ctools_export_crud_import('picture_mapping', $code);
  if (!picture_mapping_validate($mapping)) {
    form_set_error('import', t('Not a valid mapping object'));
    return;
  }
  if (picture_mapping_load($mapping->machine_name)) {
    form_set_error('import', t('A mapping with machine name %name already exists', array(
      '%name' => $mapping->machine_name,
    )));
    return;
  }
  form_set_value($form['import'], $mapping, $form_state);
}