~ubuntu-branches/ubuntu/oneiric/drupal5/oneiric

« back to all changes in this revision

Viewing changes to includes/form.inc

  • Committer: Bazaar Package Importer
  • Author(s): Emanuele Gentili
  • Date: 2008-08-15 16:15:10 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080815161510-eylf4db8xo15cz2x
Tags: 5.10-1ubuntu1
* Merge from debian unstable, remaining changes:
 + debian/patches/02_htaccess:
  - Add RewriteBase /drupal5
 + debian/control:
  - Replace exim4 with postfix in Depends.
  - Fix for debian/watch.
  - Fixed lintian warnings.
  -  add Homepage field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Id: form.inc,v 1.174.2.13 2007/12/27 08:41:52 drumm Exp $
 
2
// $Id: form.inc,v 1.174.2.14 2008/08/04 04:00:24 drumm Exp $
3
3
 
4
4
/**
5
5
 * @defgroup form Form generation
530
530
  /* Validate the current input */
531
531
  if (!isset($elements['#validated']) || !$elements['#validated']) {
532
532
    if (isset($elements['#needs_validation'])) {
533
 
      // An empty textfield returns '' so we use empty(). An empty checkbox
534
 
      // and a textfield could return '0' and empty('0') returns TRUE so we
535
 
      // need a special check for the '0' string.
536
 
      if ($elements['#required'] && empty($elements['#value']) && $elements['#value'] !== '0') {
 
533
      // Make sure a value is passed when the field is required.
 
534
      // A simple call to empty() will not cut it here as some fields, like
 
535
      // checkboxes, can return a valid value of '0'. Instead, check the
 
536
      // length if it's a string, and the item count if it's an array.
 
537
      if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
537
538
        form_error($elements, t('!name field is required.', array('!name' => $elements['#title'])));
538
539
      }
539
540