Forms

Example of displaying multiple checkboxes, with one value selected

  1. $form['option_occassions'] = array(
  2.    '#type' => 'checkboxes',
  3.   '#title' => t('Associated Occassions'),
  4.    '#options' => array(
  5.     1 => "Formal",
  6.     2 => "Social",
  7.     3 => "Xmas",

hook_ alter_form Drupal5

  1. function cckwizards_form_alter($form_id, &$form) {
  2.   if ($form_id == 'deadlines_node_forms') {
  3.    // This would put the lastnaam element at the bottom of the form.

Clearing cash so that a form re-freshes as if for the first time

  1. function string_fields_form($form, $pid) {
  2.  
  3.     // somewhere about here I ought to force this form to actually destroy any previous ideas it had of itself and start over

Form in two steps

  1. //Form 1 (a page)
  2.  
  3. <?php
  4. function oferta_mes_form()
  5. {
  6.  $form['#action'] = url('node/5'); //Importante, redirije con $_POST al siguiente form
  7.  $form['fprecio'] = array(

%crmapi_section doesn't get passed to form function

  1. function crmapi_menu() {
  2.   $items = array();
  3.   $items['crmapi/%crmapi_section'] = array(
  4.     'title callback' => 'crmapi_title',
  5.     'title arguments' => array(1),

Fix for Removing an element #process function, yuk!

  1. /**
  2.  * Implementation of hook_elements().
  3.  */
  4. function wysiwyg_elements() {
  5.   $type = array();
  6.   $type['textarea'] = array('#process' => array('wysiwyg_process_textarea'));

Removing an element #process function, yuk!

  1. /**
  2.  * Implementation of hook_form_alter().
  3.  */
  4. function wysiwyg_form_alter(&$form, &$form_state, $form_id) {
  5.   $form['#input'] = TRUE;
  6. }
  7.  
  8. function wysiwyg_process_form($form) {

Checkboxes and default_value from bldmtn

  1. /**
  2.  * Implementation of hook_form(). A multistep form that pulls in content from the database and renders it into the form based
  3.  
Syndicate content