Details
-
Story
-
Resolution: Fixed
-
High
-
None
Description
In the current situation, a ContentValidationException exception is thrown (https://github.com/ezsystems/ezp-next/blob/master/eZ/Publish/Core/Repository/ContentService.php#L542) when the field is marked as required and the field has not been set at all.
However, setting it with empty content will not trigger it:
$content->setField( "requiredTextLineField", "" );
The method isEmptyValue() (https://github.com/ezsystems/ezp-next/blob/master/eZ/Publish/Core/FieldType/FieldType.php#L258) is used to test emptyness in a very generic way and is until now, never overridden:
public function isEmptyValue( $value ) { return ( $value == $this->getEmptyValue() ); }
Some field types' getEmptyValue() returns null, some returns a Value object.
The values used for emptyness has been summarized in a document: https://docs.google.com/a/schlitt.info/spreadsheet/ccc?key=0ApxQ-KCWjCMBdFItWlRuQ2ptZFNsNFFOb3VHZ1BXR2c but it looks out of sync with the ones returning a Value object.
Approach 1: Shouldn't all getEmptyValue() return a Value object? Which can be used by isEmptyValue() to compare with the == operator for most Field Types? And more complex ones would override the isEmptyValue() (XmlText for example).
Approach 2: Should the current return values of getEmptyValue() be preserved and isEmptyValue() surround calls to getEmptyValue() with acceptValue():
public function isEmptyValue( $value ) { return ( $value == $this->acceptValue( $this->getEmptyValue() ) ); }
Approach 3: Nor getEmptyValue() nor isEmptyValue() should be changed, isEmptyValue() should be implemented for most field types.
Attachments
Issue Links
- is duplicated by
-
EZP-20030 publicAPI: Not possible to make a object with xmltext field type if that fieldtype is "Required"
- Closed