Exemple #1
0
 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);
 }
Exemple #2
0
 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);
 }
Exemple #4
0
 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));
 }
Exemple #5
0
 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);
 }
Exemple #6
0
 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()));
 }
Exemple #7
0
 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()));
 }
Exemple #8
0
 public function render(Entity $entity)
 {
     return Entity::html('span', array(), htmlspecialchars($entity->getInitial()));
 }
Exemple #9
0
 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);
 }
Exemple #10
0
 public function renderBody(Entity $entity)
 {
     $title = $entity->getLabel() !== '' ? Entity::html('label', array(), htmlspecialchars($entity->getLabel())) : '';
     return $title . $entity->renderDescription() . $entity->renderErrors() . $this->renderChildren($entity);
 }
Exemple #11
0
 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()));
 }
Exemple #13
0
 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);
 }