public function render(Entity $entity) { $datalist = ''; if (count($this->datalist)) { foreach ($this->datalist as $value) { $datalist .= Entity::html('option', array('value' => $value)); } $datalist = Entity::html('datalist', array('id' => $entity->getId() . '-datalist'), $datalist); } $attr = $this->attributes + array('type' => $this->type, 'id' => $entity->getId(), 'required' => $entity->getRequired(), 'name' => $entity->getFullName(), 'value' => $this->getValue($entity), 'list' => $datalist ? $entity->getId() . '-datalist' : null); return $datalist . Entity::html('input', $attr); }
protected function buildChoices($name, $id, $choices, $selected, $disabled) { $output = " "; foreach ($choices as $k => $v) { if (is_array($v)) { $output .= Entity::html('div', array(), Entity::html('span', array(), $k) . $this->buildChoices($name, $id, $v, $selected, $disabled)); } else { $attr = array('type' => 'radio', 'value' => $k, 'checked' => in_array($k, $selected), 'disabled' => in_array($k, $disabled), 'id' => $id . '-' . $k, 'name' => $name); $output .= Entity::html('label', array('for' => $attr['id']), Entity::html('input', $attr) . ' ' . htmlspecialchars($v) . ' '); } } return $output; }
public function renderNormal(Entity $entity) { $markup = ""; foreach ($entity as $columnEntity) { if (!$entity instanceof Container) { throw new \Exception('CollectionTabular requires entities to be subclass of \\Curry\\Form\\Container'); } $attr = array('class' => $columnEntity->getWrapperClass()); $markup .= Entity::html('td', $attr, $columnEntity->render()); } $attr = array('class' => $entity->getWrapperClass()); return Entity::html('tr', $attr, $markup); }
public function render(Entity $entity) { $value = $entity->getValue(); $attr = $this->attributes + array('type' => $this->type, 'id' => $entity->getId(), 'name' => $entity->getFullName()); if ($entity->isArray()) { $output = ""; foreach ($value as $v) { // TODO: does not preserve keys, is this ok? $output .= Entity::html('input', $attr + array('value' => $v)); } return $output; } return Entity::html('input', $attr + array('value' => $value)); }
public function render(Entity $entity) { $attr = $this->attributes + array('type' => $this->type, 'id' => $entity->getId(), 'required' => $entity->getRequired(), 'name' => $entity->getFullName(), 'multiple' => $entity->isArray()); return Entity::html('input', $attr); }
public function renderNormal(Entity $entity) { $attr = array('class' => $entity->getWrapperClass()); return Entity::html('tr', $attr, Entity::html('td', array(), $entity->isLabelOutside() ? $entity->renderLabel() : ' ') . Entity::html('td', array(), $entity->render() . $entity->renderDescription() . $entity->renderErrors())); }
public function render(Entity $entity) { $attr = $this->attributes + array('id' => $entity->getId(), 'name' => $entity->getFullName(), 'required' => $entity->getRequired()); return Entity::html('textarea', $attr, htmlspecialchars($entity->getValue())); }
public function render(Entity $entity) { return Entity::html('span', array(), htmlspecialchars($entity->getInitial())); }
public function render(Entity $entity) { $legend = $entity->getLabel() !== '' ? Entity::html('legend', array(), htmlspecialchars($entity->getLabel())) : ''; $markup = $legend . $entity->renderDescription() . $entity->renderErrors() . $this->renderChildren($entity); return Entity::html('fieldset', $this->attributes, $markup); }
public function renderBody(Entity $entity) { $title = $entity->getLabel() !== '' ? Entity::html('label', array(), htmlspecialchars($entity->getLabel())) : ''; return $title . $entity->renderDescription() . $entity->renderErrors() . $this->renderChildren($entity); }
public function render(Entity $entity) { $attr = $this->attributes + array('id' => $entity->getId(), 'type' => $this->type, 'name' => $entity->getFullName()); return Entity::html('button', $attr, htmlspecialchars($entity->getLabel())); }
public function render(Entity $entity) { $attr = $this->attributes + array('id' => $entity->getId(), 'name' => $entity->getFullName()); return Entity::html('select', $attr, $this->buildChoices($this->getChoices(), (array) $entity->getValue(), $this->getDisabledChoices())); }
public function renderNormal(Entity $entity) { $attr = array('id' => $entity->getId() . '-label', 'class' => $entity->getWrapperClass()); return Entity::html('dt', $attr, $entity->isLabelOutside() ? $entity->renderLabel() : '') . Entity::html('dd', array('id' => $entity->getId() . '-element'), $entity->render() . $entity->renderDescription() . $entity->renderErrors()); }
public function renderNormal(Entity $entity) { $attr = array('class' => $entity->getWrapperClass()); $markup = ($entity->isLabelOutside() ? $entity->renderLabel() : '') . $entity->render() . $entity->renderDescription() . $entity->renderErrors(); return Entity::html('div', $attr, $markup); }