/** * Test setting and getting single values */ public function test_single() { $col = $this->makeColumn(false); $val = new Value($col, 'one'); $this->assertSame($col, $val->getColumn()); $this->assertEquals('one', $val->getValue()); $val->setValue('0'); $this->assertEquals('0', $val->getValue()); $val->setValue(''); $this->assertEquals('', $val->getValue()); $val->setValue(" \n"); $this->assertEquals('', $val->getValue()); $val->setValue(null); $this->assertEquals('', $val->getValue()); $val->setValue(false); $this->assertEquals('', $val->getValue()); $val->setValue(array('what', 'the', 'foo')); $this->assertEquals('what', $val->getValue()); $val->setValue(array()); $this->assertEquals('', $val->getValue()); }
/** * Create the input field * * @param Value $field * @param String $name field's name * @return string */ public function makeField(Value $field, $name) { $trans = hsc($field->getColumn()->getTranslatedLabel()); $hint = hsc($field->getColumn()->getTranslatedHint()); $class = $hint ? 'hashint' : ''; $colname = $field->getColumn()->getFullQualifiedLabel(); $input = $field->getValueEditor($name); // we keep all the custom form stuff the field might produce, but hide it if (!$field->getColumn()->isVisibleInEditor()) { $hide = 'style="display:none"'; } else { $hide = ''; } $html = ''; $html .= "<label {$hide} data-column=\"{$colname}\">"; $html .= "<span class=\"label {$class}\" title=\"{$hint}\">{$trans}</span>"; $html .= "<span class=\"input\">{$input}</span>"; $html .= '</label>'; return $html; }
/** * Check if the given row is empty or references our own row * * @param Value $value * @return bool */ protected function isEmptyValue(Value $value) { if ($value->isEmpty()) { return true; } if ($value->getColumn()->getTid() == 0) { return true; } return false; }
/** * Create the input field * * @param Value $field * @param String $name field's name * @return string */ protected function makeField(Value $field, $name) { $trans = hsc($field->getColumn()->getTranslatedLabel()); $hint = hsc($field->getColumn()->getTranslatedHint()); $class = $hint ? 'hashint' : ''; $lclass = $this->error ? 'bureaucracy_error' : ''; $colname = $field->getColumn()->getFullQualifiedLabel(); $required = $this->opt['optional'] ? '' : ' <sup>*</sup>'; $input = $field->getValueEditor($name); $html = ''; $html .= "<label class=\"{$lclass}\" data-column=\"{$colname}\">"; $html .= "<span class=\"label {$class}\" title=\"{$hint}\">{$trans}{$required}</span>"; $html .= "<span class=\"input\">{$input}</span>"; $html .= '</label>'; return $html; }