fapi

D6 FAPI Examples

  1. <?php
  2. // $Id: $
  3.  
  4. /**
  5.  * @file
  6.  * Makes a Form.
  7.  *
  8.  */
  9. function form_intro_menu() {
  10.  
  11.   $items = array();
  12.   $items['survey'] = array(
  13.     'title' => 'Super Sweet Survey',

Code

  1. <?php
  2.  
  3. function my_module_menu() {
  4.   $items = array();
  5.   $items['my_module/form'] = array(
  6.     'title' => t('My form'),
  7.     'page callback' => 'my_module_form',

formulario

  1. <code>
  2. <?php
  3.  
  4. /**
  5. * Formulario que permite guardar las partidas jugadas
  6. * Form to save the game.
  7. */
  8.  
  9. function alta_partida_form($node){
  10.         $form['alta_partida'] = array (

formulario

  1. <code>
  2. <?php
  3.  
  4. /**
  5. * Formulario que permite guardar las partidas jugadas
  6. * Form to save the game.
  7. */
  8.  
  9. function alta_partida_form($node){
  10.         $form['alta_partida'] = array (

Adding submit handlers in D6

  1. /**
  2.  * Implementation of hook_form_alter().
  3.  */
  4. function hs_taxonomy_form_alter(&$form, &$form_state, $form_id) {
  5.   // Add per-vocabulary settings for Hierarchical Select.

Fix for Trying to insert text into &quot;subject&quot; field of the comments form.

  1. /**
  2.    * Implements hook_form_alter.
  3.    * Client wants the subject field to initially be blank.
  4.    * If the user doesn't type in a subject line, then the
  5.  

Fix for Trying to insert text into &quot;subject&quot; field of the comments form.

  1. /**
  2.    * Implements hook_form_alter.
  3.    * Client wants the subject field to initially be blank.
  4.    * If the user doesn't type in a subject line, then the
  5.  

Fix for Code

  1. phptemplate_form($element) {
  2.   $id ='id1,id2,id3,id4,en,nog,een,id';
  3.   if (in_array($element['#id'], explode(',', $id))) {
  4.     $element['attributes']['class'] .= 'JOUWCUSTOMCLASS';
  5.   }

Fix for Code

  1. phptemplate_form($element) {
  2.   $id = 'id1,id2,id3,id4,en,nog,een,id';
  3.   if (strpos($id, $element['#id']) !== FALSE) {
  4.     $element['attributes']['class'] .= 'JOUWCUSTOMCLASS';
  5.   }

Fix for Edit a hidden value with jQuery and have it show up in $form_values (D5)

  1. <?php
  2.  
  3. /**
  4.  * This won't work when you first submit it... the hider will still show 3.
  5.  * Change #value to #default_value on the hidden field for it to work.
  6.  */
  7.  
  8. function test_form() {
Syndicate content