1 block.hero.inc BlockHero::formSubmit($form, &$form_state)

Submit handler to save the form settings.

Overrides BlockText::formSubmit

File

core/modules/layout/includes/block.hero.inc, line 94

Class

BlockHero
BlockHero extends BlockText

Code

function formSubmit($form, &$form_state) {
  parent::formSubmit($form, $form_state);

  // Save the things not handled by BlockText.
  if (isset($form_state['values']['image']) && $form_state['values']['image'] != 0) {
    // Record that the layout module is using this file. Also marks permanent.
    $file = file_load($form_state['values']['image']);
    file_usage_add($file, 'layout', 'block', $file->fid);

    // Store the filepath separately for use as inline background image.
    $absolute_path = parse_url($GLOBALS['base_url'], PHP_URL_PATH) . '/';
    $fileurl = file_create_url($file->uri);
    $filepath = str_replace($GLOBALS['base_url'] . '/', $absolute_path, $fileurl);
    $form_state['values']['image_path'] = $filepath;

    $this->settings['image'] = $form_state['values']['image'];
    $this->settings['image_path'] = $form_state['values']['image_path'];
  }
  else {
    $this->settings['image'] = NULL;
    $this->settings['image_path'] = NULL;
  }
}