Browse files

BUGFIX Correctly mark DatetimeField, MoneyField and PhoneNumberField …

…composites as disabled or readonly
  • Loading branch information...
1 parent 4056b94 commit e31851b1827d25a5c2c532c6e8b9b7c566a31387 @chillu chillu committed Jan 2, 2012
Showing with 50 additions and 25 deletions.
  1. +14 −0 forms/DatetimeField.php
  2. +3 −0 forms/HtmlEditorField.php
  3. +9 −4 forms/MoneyField.php
  4. +24 −21 forms/PhoneNumberField.php
View
14 forms/DatetimeField.php
@@ -181,6 +181,20 @@ function Value() {
return sprintf($this->getConfig('datetimeorder'), $valDate, $valTime);
}
+
+ function setDisabled($bool) {
+ parent::setDisabled($bool);
+ $this->dateField->setDisabled($bool);
+ $this->timeField->setDisabled($bool);
+ if($this->timezoneField) $this->timezoneField->setDisabled($bool);
+ }
+
+ function setReadonly($bool) {
+ parent::setReadonly($bool);
+ $this->dateField->setReadonly($bool);
+ $this->timeField->setReadonly($bool);
+ if($this->timezoneField) $this->timezoneField->setReadonly($bool);
+ }
/**
* @return DateField
View
3 forms/HtmlEditorField.php
@@ -175,6 +175,9 @@ public function performReadonlyTransformation() {
return $field;
}
+ public function performDisabledTransformation() {
+ return $this->performReadonlyTransformation();
+ }
}
/**
View
13 forms/MoneyField.php
@@ -127,10 +127,15 @@ function performReadonlyTransformation() {
function setReadonly($bool) {
parent::setReadonly($bool);
- if($bool) {
- $this->fieldAmount = $this->fieldAmount->performReadonlyTransformation();
- $this->fieldCurrency = $this->fieldCurrency->performReadonlyTransformation();
- }
+ $this->fieldAmount->setReadonly($bool);
+ $this->fieldCurrency->setReadonly($bool);
+ }
+
+ function setDisabled($bool) {
+ parent::setDisabled($bool);
+
+ $this->fieldAmount->setDisabled($bool);
+ $this->fieldCurrency->setDisabled($bool);
}
/**
View
45 forms/PhoneNumberField.php
@@ -28,33 +28,36 @@ public function __construct( $name, $title = null, $value = '', $extension = nul
}
public function Field() {
- $field = new FieldGroup( $this->name );
- $field->setID("{$this->name}_Holder");
-
-
- list( $countryCode, $areaCode, $phoneNumber, $extension ) = $this->parseValue();
-
+ $fields = new FieldGroup( $this->name );
+ $fields->setID("{$this->name}_Holder");
+ list($countryCode, $areaCode, $phoneNumber, $extension) = $this->parseValue();
$hasTitle = false;
- if ($this->value=="")
- {
- $countryCode=$this->countryCode;
- $areaCode=$this->areaCode;
- $extension=$this->ext;
- }
+ if ($this->value=="") {
+ $countryCode=$this->countryCode;
+ $areaCode=$this->areaCode;
+ $extension=$this->ext;
+ }
- if( $this->countryCode !== null )
- $field->push( new NumericField( $this->name.'[Country]', '+', $countryCode, 4 ) );
+ if($this->countryCode !== null) {
+ $fields->push(new NumericField($this->name.'[Country]', '+', $countryCode, 4));
+ }
- if( $this->areaCode !== null ){
- $field->push( new NumericField( $this->name.'[Area]', '(', $areaCode, 4 ) );
- $field->push( new NumericField( $this->name.'[Number]', ')', $phoneNumber, 10 ) );
- }else{
- $field->push( new NumericField( $this->name.'[Number]', '', $phoneNumber, 10 ) );
+ if($this->areaCode !== null) {
+ $fields->push(new NumericField($this->name.'[Area]', '(', $areaCode, 4));
+ $fields->push(new NumericField($this->name.'[Number]', ')', $phoneNumber, 10));
+ } else {
+ $fields->push(new NumericField($this->name.'[Number]', '', $phoneNumber, 10));
}
- if( $this->ext !== null )
- $field->push( new NumericField( $this->name.'[Extension]', 'ext', $extension, 6 ) );
+ if($this->ext !== null) {
+ $field->push(new NumericField( $this->name.'[Extension]', 'ext', $extension, 6));
+ }
+
+ foreach($fields as $field) {
+ $field->setDisabled($this->isDisabled());
+ $field->setReadonly($this->isReadonly());
+ }
return $field;
}

0 comments on commit e31851b

Please sign in to comment.