BUGFIX Correctly mark DatetimeField, MoneyField and PhoneNumberField composites as disabled or readonly

This commit is contained in:
Ingo Schommer 2012-01-02 16:19:22 +01:00
parent 4056b94f75
commit e31851b182
4 changed files with 50 additions and 25 deletions

View File

@ -181,6 +181,20 @@ class DatetimeField extends FormField {
return sprintf($this->getConfig('datetimeorder'), $valDate, $valTime); 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 * @return DateField

View File

@ -175,6 +175,9 @@ class HtmlEditorField extends TextareaField {
return $field; return $field;
} }
public function performDisabledTransformation() {
return $this->performReadonlyTransformation();
}
} }
/** /**

View File

@ -127,10 +127,15 @@ class MoneyField extends FormField {
function setReadonly($bool) { function setReadonly($bool) {
parent::setReadonly($bool); parent::setReadonly($bool);
if($bool) { $this->fieldAmount->setReadonly($bool);
$this->fieldAmount = $this->fieldAmount->performReadonlyTransformation(); $this->fieldCurrency->setReadonly($bool);
$this->fieldCurrency = $this->fieldCurrency->performReadonlyTransformation(); }
}
function setDisabled($bool) {
parent::setDisabled($bool);
$this->fieldAmount->setDisabled($bool);
$this->fieldCurrency->setDisabled($bool);
} }
/** /**

View File

@ -28,33 +28,36 @@ class PhoneNumberField extends FormField {
} }
public function Field() { public function Field() {
$field = new FieldGroup( $this->name ); $fields = new FieldGroup( $this->name );
$field->setID("{$this->name}_Holder"); $fields->setID("{$this->name}_Holder");
list($countryCode, $areaCode, $phoneNumber, $extension) = $this->parseValue();
list( $countryCode, $areaCode, $phoneNumber, $extension ) = $this->parseValue();
$hasTitle = false; $hasTitle = false;
if ($this->value=="") if ($this->value=="") {
{ $countryCode=$this->countryCode;
$countryCode=$this->countryCode; $areaCode=$this->areaCode;
$areaCode=$this->areaCode; $extension=$this->ext;
$extension=$this->ext; }
}
if( $this->countryCode !== null ) if($this->countryCode !== null) {
$field->push( new NumericField( $this->name.'[Country]', '+', $countryCode, 4 ) ); $fields->push(new NumericField($this->name.'[Country]', '+', $countryCode, 4));
}
if( $this->areaCode !== null ){ if($this->areaCode !== null) {
$field->push( new NumericField( $this->name.'[Area]', '(', $areaCode, 4 ) ); $fields->push(new NumericField($this->name.'[Area]', '(', $areaCode, 4));
$field->push( new NumericField( $this->name.'[Number]', ')', $phoneNumber, 10 ) ); $fields->push(new NumericField($this->name.'[Number]', ')', $phoneNumber, 10));
}else{ } else {
$field->push( new NumericField( $this->name.'[Number]', '', $phoneNumber, 10 ) ); $fields->push(new NumericField($this->name.'[Number]', '', $phoneNumber, 10));
} }
if( $this->ext !== null ) if($this->ext !== null) {
$field->push( new NumericField( $this->name.'[Extension]', 'ext', $extension, 6 ) ); $field->push(new NumericField( $this->name.'[Extension]', 'ext', $extension, 6));
}
foreach($fields as $field) {
$field->setDisabled($this->isDisabled());
$field->setReadonly($this->isReadonly());
}
return $field; return $field;
} }