Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FEATURE: Added ability to query size of Varchar

This allows a developer to programatically access the size of the DB Varchar field. This allows us to be a bit more DRY and to define the size in one place and limit TextFields to the same value
  • Loading branch information...
commit f0621cdd91c5fc2a972d3869fd202f1a4bb32c08 1 parent accbd7f
@dhensby dhensby authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 model/fieldtypes/Varchar.php
View
13 model/fieldtypes/Varchar.php
@@ -33,6 +33,19 @@ public function __construct($name = null, $size = 50, $options = array()) {
}
/**
+ * Allow the ability to access the size of the field programatically. This
+ * can be useful if you want to have text fields with a length limit that
+ * is dictated by the DB field.
+ *
+ * TextField::create('Title')->setMaxLength(singleton('SiteTree')->dbObject('Title')->getSize())
+ *
+ * @return int The size of the field
+ */
+ public function getSize() {
+ return $this->size;
+ }
+
+ /**
* (non-PHPdoc)
* @see DBField::requireField()
*/

0 comments on commit f0621cd

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