protected function populateElement(Element $element) { $name = $element->getName(); if ($name && $this->record->keyExists($name)) { if ($element->getAttribute('type') == 'checkbox') { $element->setValue(1); if ($this->record->{$name}) { $element->setAttribute('checked', 'checked'); } } elseif ($element->getAttribute('type') == 'password') { // do nothing } else { $element->setValue($this->record->{$name}); } } }
/** * @param Element $element * * @return string */ public function getAngularJSValidator(Element $element) { $name = $element->getAttribute('name'); $form = $element->closest('form'); $formName = $form ? $form->getName() : 'form' . ucfirst(substr($name, 0, strpos($name, '['))); return $formName . '[\'' . $name . '\'].$error.required'; }
/** * @param Element $element * * @return mixed|object */ protected function wrapIntoLabel(Element $element) { $wrapper = $this->elementFactory->create("Label"); if ($id = $element->getAttribute('id')) { $wrapper->setAttribute('for', $id); } if ($this->label) { $element->addSibling($this->label); } $element->setDecoratedParent($wrapper); return $wrapper; }