You are here

function multiblock_add_form_validate in MultiBlock 5

Same name and namespace in other branches
  1. 6 multiblock.module \multiblock_add_form_validate()
  2. 7 multiblock.module \multiblock_add_form_validate()

Validate "Add Block Instance" form.

File

./multiblock.module, line 223

Code

function multiblock_add_form_validate($form_id, $form_values) {
  if (!isset($form_values['instance'])) {

    // Make sure we are getting a valid block to add.
    if (!preg_match('/^.+\\*\\*\\*MB\\*\\*\\*.+$/', $form_values['block'])) {
      form_set_error('block', t('Bad block module input, contact administrator'));
      return;
    }

    // Make sure the block and delta exist.
    $orig_block = multiblock_blockinfo_from_form($form_values['block']);
    if (!module_hook($orig_block['module'], 'block') || !array_key_exists($orig_block['delta'], module_invoke($orig_block['module'], 'block', 'list'))) {
      form_set_error('block', t('Module or block doesn\'t exist, contact administrator'));
    }
  }
}