Portal : Finished integration of Date & DateTime attributes in forms

SVN:trunk[4029]
This commit is contained in:
Guillaume Lajarige
2016-05-04 09:42:14 +00:00
parent dc5040c1d2
commit 2b12a86fa8
3 changed files with 20 additions and 2 deletions

View File

@@ -3646,6 +3646,7 @@ class AttributeDateTime extends AttributeDBField
$oFormField = parent::MakeFormField($oObject, $oFormField);
$oFormField->SetPHPDateTimeFormat((string) $this->GetFormat());
$oFormField->SetJSDateTimeFormat($this->GetFormat()->ToMomentJS());
$oFormField->SetCurrentValue($this->GetFormat()->Format($oObject->Get($this->GetCode())));
return $oFormField;
}

View File

@@ -84,7 +84,7 @@ class DateTimeField extends StringField
public function GetDisplayValue()
{
return AttributeDatetime::GetFormat()->Format($this->currentValue);
return $this->currentValue;
}
/**
@@ -103,4 +103,5 @@ class DateTimeField extends StringField
{
return $this->bDateOnly;
}
}

View File

@@ -260,7 +260,7 @@ EOF
}
$oOutput->AddHtml('<div class="form-control-static">')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('</div>');
}
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetCurrentValue(), true)->AddHtml('" class="form-control" />');
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')->AddHtml($this->oField->GetDisplayValue(), true)->AddHtml('" class="form-control" />');
$oOutput->AddHtml('</div>');
break;
@@ -310,6 +310,22 @@ EOF
EOF
);
break;
case 'Combodo\\iTop\\Form\\Field\\DateTimeField':
// We need the focusout event has the datepicker widget seems to override the change event
$oOutput->AddJs(
<<<EOF
$("#{$this->oField->GetGlobalId()}").off("change keyup focusout").on("change keyup focusout", function(){
var me = this;
$(this).closest(".field_set").trigger("field_change", {
id: $(me).attr("id"),
name: $(me).closest(".form_field").attr("data-field-id"),
value: $(me).val()
});
});
EOF
);
break;
case 'Combodo\\iTop\\Form\\Field\\RadioField':
case 'Combodo\\iTop\\Form\\Field\\CheckboxField':