/[drupal]/drupal/modules/simpletest/tests/field_test.module
ViewVC logotype

Diff of /drupal/modules/simpletest/tests/field_test.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.36, Sat Oct 31 16:06:36 2009 UTC revision 1.37, Sun Nov 1 14:05:32 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: field_test.module,v 1.35 2009/10/24 17:02:51 webchick Exp $  // $Id: field_test.module,v 1.36 2009/10/31 16:06:36 dries Exp $
3    
4  define('FIELD_TEST_ELEMENT_ID', 1);  define('FIELD_TEST_ELEMENT_ID', 1);
5  define('FIELD_TEST_BUNDLE', 'test_bundle');  define('FIELD_TEST_BUNDLE', 'test_bundle');
# Line 489  function field_test_field_widget_info() Line 489  function field_test_field_widget_info()
489    
490  /**  /**
491   * Implement hook_field_widget().   * Implement hook_field_widget().
  *  
  * Attach a single form element to the form. It will be built out and  
  * validated in the callback(s) listed in hook_element_info(). We build it  
  * out in the callbacks rather than here in hook_widget so it can be  
  * plugged into any module that can provide it with valid  
  * $field information.  
  *  
  * If there are multiple values for this field, the field module will  
  * call this function as many times as needed.  
  *  
  * @param $form  
  *   the entire form array, $form['#node'] holds node information  
  * @param $form_state  
  *   the form_state, $form_state['values'][$field['field_name']]  
  *   holds the field's form values.  
  * @param $field  
  *   The field structure.  
  * @param $instance  
  *   the instance array  
  * @param $items  
  *   array of default values for this field  
  * @param $delta  
  *   the order of this item in the array of subelements (0, 1, 2, etc)  
  *  
  * @return  
  *   the form item for a single element for this field  
492   */   */
493  function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {  function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
494    $element = array(    $element = array(
495      'value' => array(      'value' => $element + array(
       '#title' => $instance['label'],  
496        '#type' => 'textfield',        '#type' => 'textfield',
497        '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',        '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
       '#required' => $instance['required'],  
498      ),      ),
499    );    );
500    return $element;    return $element;

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.2