Development

#3480 ([PATCH] Form: Enable attributes in sfWidgetFormDate)

You must first sign up to be able to contribute.

Ticket #3480 (closed enhancement: fixed)

Opened 5 months ago

Last modified 5 months ago

[PATCH] Form: Enable attributes in sfWidgetFormDate

Reported by: thomas.s Assigned to: fabien
Priority: minor Milestone: 1.1.0 RC2
Component: form Version: 1.1.0 RC1
Keywords: disable sfWidgetFormDate Cc:
Qualification: Unreviewed

Description

When trying to disable a sfWidgetFormDate widget with $widget->setAttribute('disabled', 'disable'), the class sfWidgetFormDate creates three widgets of type sfWidgetFormSelect but ignores the attribute "disabled".

/**
   * @see sfWidgetForm
   */
  public function render($name, $value = null, $attributes = array(), $errors = array())
  {...

    // days
    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['day']) + $this->getOption('days') : $this->getOption('days')));
    $date['%day%'] = $widget->render($name.'[day]', $value['day']);

    // months
    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['month']) + $this->getOption('months') : $this->getOption('months')));
    $date['%month%'] = $widget->render($name.'[month]', $value['month']);

    // years
    $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['year']) + $this->getOption('years') : $this->getOption('years')), $attributes);
    $date['%year%'] = $widget->render($name.'[year]', $value['year']);

    return strtr($this->getOption('format'), $date);
  }

The array $attributes is never passed to the sfWidgetFormSelect constructor, passing it solves this issue (see attached patch).

Attachments

sfWidgetFormDate.diff (1.9 kB) - added by thomas.s on 05/06/08 01:11:28.
Enable the sfWidgetFormDate to be disabled.

Change History

05/06/08 01:11:28 changed by thomas.s

  • attachment sfWidgetFormDate.diff added.

Enable the sfWidgetFormDate to be disabled.

05/10/08 23:37:44 changed by fabien

  • version changed from 1.0.13 to 1.1.0 RC1.
  • milestone set to 1.1.0 RC2.

05/10/08 23:39:18 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

(In [8907]) fixed HTML attributes for Date, Time, and DateTime? widgets (closes #3480)