Skip to content
Browse files

Disallow invalid element texts.

  • Loading branch information...
1 parent e97d0d5 commit 498a9bcc900a47578f68ceef5a6f46cbe6715269 @zerocrates zerocrates committed Jul 2, 2012
Showing with 17 additions and 1 deletion.
  1. +17 −1 application/models/ElementText.php
View
18 application/models/ElementText.php
@@ -20,7 +20,23 @@ class ElementText extends Omeka_Record
public $element_id;
public $html = 0;
public $text;
-
+
+ /**
+ * Validate the element text prior to saving.
+ */
+ protected function _validate()
+ {
+ if ($this->record_id < 1) {
+ $this->addError('record_id', __('Invalid record ID.'));
+ }
+ if (empty($this->record_type)) {
+ $this->addError('record_type', __('All element texts must have a record type.'));
+ }
+ if ($this->element_id < 1) {
+ $this->addError('element_id', __('Invalid element ID.'));
+ }
+ }
+
public function __toString()
{
return (string) $text;

0 comments on commit 498a9bc

Please sign in to comment.
Something went wrong with that request. Please try again.