Skip to content

Commit

Permalink
Merge pull request #24 from netgen/bugfix-required-field
Browse files Browse the repository at this point in the history
Make sure validation fails if the field is required, but no media has been selected
  • Loading branch information
iherak authored Jan 19, 2018
2 parents 64efc9a + 75716b2 commit 6c9c789
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ function __construct()
*/
public function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
$contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );

$resourceId = trim( $http->postVariable( $base . '_media_id_' . $contentObjectAttributeID, '' ) );

if ( (empty($resourceId) || $resourceId === 'removed') && $contentObjectAttribute->validateIsRequired() )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ngremotemedia/datatypes', 'It is required to select media.' ) );
return eZInputValidator::STATE_INVALID;
}

return eZInputValidator::STATE_ACCEPTED;
}

Expand Down

0 comments on commit 6c9c789

Please sign in to comment.