1 <?php
2 3 4 5 6 7
8 class TextFieldWithEmptyFlag extends TextField {
9
10 protected $emptyFlagField = null;
11
12 function __construct($name, $title = null, $value = "", $className = 'NumericField'){
13 $this->emptyFlagField = new CheckboxField($name . '[IsEmpty]');
14 parent::__construct($name, $title, $value);
15 }
16
17 function setForm($form) {
18 parent::setForm($form);
19 $this->emptyFlagField->setForm($form);
20 }
21
22 function Field() {
23 Requirements::javascript('site/javascript/empty_field.js');
24 $field = parent::Field();
25 return $field . '<label class="label-empty">' . $this->emptyFlagField->Field() . _t('TextFieldWithEmptyFlag.empty', 'empty') . '</label>';
26 }
27 }
28
29
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-