You are here

function YOURMODULE_custom_form in Visual select file 7

Some custom form on your website, maybe global, or per-domain, or not.

File

./visual_select_file.api.php, line 41

Code

function YOURMODULE_custom_form($form, &$form_state) {
  $form['test_wysiwyg3'] = array(
    '#type' => 'text_format',
    '#title' => t('Pretty text 3'),
    '#default_value' => $value['value'],
    '#format' => $value['format'],
    // The type of file usage/form/config we are now. For entities, this is the entity type, but
    // that's not so for custom forms. A common practice is using the form name.
    '#vsf_file_usage_type' => 'YOURMODULE_custom_form',
    // The instance of the above type you defined. For entities, this is the entity id, but any
    // ID will do. A few examples:
    // Note. {file_usage} only saves 32 bit ints, so strings will be converted using crc32().
    // This form has many many WYSIWYG fields, so I want per-field usage.
    '#vsf_file_usage_id' => 'test_wysiwyg3',
    // This form is global, once, entire site, so ANY ID will do, so keep it simple.
    '#vsf_file_usage_id' => 1,
    // This very form is used for a few Domains, so defaults and values are domain-specific. Kind of
    // like an entity id, but per-domain.
    '#vsf_file_usage_id' => $domain['domain_id'],
  );

  // Custom forms that save into variables use this. Use whatever submit handler you want, but ADD
  // MINE TOO!
  $form = system_settings_form($form);

  // If you want automatic file_usage, YOU NEED THIS SUBMIT HANDLER.
  $form['#submit'][] = 'vsf_wysiwyg_save_file_usage_submit';

  // Note. If you don't care about {file_usage} at all (you silly you!), you don't need #vsf_file_usage_type
  // and #vsf_file_usage_id, but you will need #entity_type, #bundle and #field_name.
  // @see vsf_wysiwyg_pre_render_wysiwyg_element()
  return $form;
}