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);
}
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 File

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

View File

@ -127,10 +127,15 @@ class MoneyField extends FormField {
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 File

@ -28,33 +28,36 @@ class PhoneNumberField extends FormField {
}
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;
}