Form API

Fix for Ejemplo de select. Form API

  1. //$meses array que la key es el "valor" retornado, y el valor es el nombre mostrado, ejemplo
  2.  
  3. $meses[1]="Enero";
  4. $meses[2]="Febrero";
  5. $meses[3]="Marzo";
  6. $meses[4]="Abril";
  7. $meses[5]="Mayo";
  8. $me

Fix for attempting to create a date_popup form element

  1. $form['start_date'] = array(
  2.         '#type' => 'date_popup',
  3.         '#title' => t('Start Date'),
  4.         '#date_timezone' => date_default_timezone_name(),
  5.         '#date_format' => 'F j, Y',
  6.         '#date_increment' => 1,
  7.         '#d

Fix for attempting to create a date_popup form element

  1. $form['start_date'] = array(
  2.         '#type' => 'date_popup',
  3.         '#title' => t('Start Date'),
  4.         '#date_timezone' => date_default_timezone_name(),
  5.         '#date_format' => 'F j, Y',
  6.         '#date_increment' => 1,
  7.         '#d

Simple problem: Extracting value from $form['ounces']

  1. <?php
  2. // $Id$
  3.  
  4. /* This function will ultimately do a conversion, but for right now
  5. *  I'm just trying to get it to regurgitate the value of $form['ounces']
  6. *  back at me when I click the "Conver

Crazy form

  1. function book_access_permissions_form(&$form_state, $node) {
  2.   $grants = array(
  3.     'view' => array(),
  4.     'update' => array(),
  5.     'delete' => array(),
  6.   );
  7.   $grant_ids = array(
  8.     'grant_vi

Output of drupal_render

  1. <div class="form-item">
  2.  <label>Rol: </label>
  3.  <div class="form-radios"></div>
  4. </div>
  5. <div class="form-item">
  6.  <label>Projectfase: </label>
  7.  <div class="form-checkboxes"></div>
  8. </div>
  9. <div cla

default value for select element

  1. /*
  2. * i want to do a simple thing: populate a select field with the chosen value after a form submit.

Fix for changing user login block template

  1. <?php
  2.  
  3. $form['name']['#title'] = $form['pass']['#title'] = '';
  4.  
  5. $form['name']['#size'] = 6;
  6.  
  7. ?>
  8. <div id="user_login_block">
  9.  
  10. <div id="user-name"><?php print drupal_render($form['name']); ?></

form API bug

  1. function chatroom_test_multiform_bug_page_callback() {
  2.   $output = '<h2>Test mulitple forms on the one page</h2>';
  3.   foreach (range(1, 5) as $counter) {
  4.     $output .= drupal_get_form('chatroom_tes
fallsemo's picture

Validating and Submitting a form to an external mailing list.

  1. <?php
  2. // $Id$
  3.  
  4. /**
  5.  *Implementation of hook_menu().
Syndicate content