/** * Render html of field. * * @return string */ public function render() { $attrs = array(); $id = $this->getHtmlId(); $name = $this->getHtmlName(); $label = $this->getLabel(); $img = ''; $cssClass = 'file'; $errorMessage = ''; $attrs['id'] = $id; if (!$this->isValid) { $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage()); $cssClass .= ' error'; } if ($this->getOption('required') == 'true') { $cssClass .= ' required'; } if ($this->value) { $imgPath = $this->getDisplayValue(); $img = sprintf("<img src='%s' width='90' height='90' />", $imgPath); } $attrs['class'] = $cssClass; $html = ''; if (!empty($label)) { $html .= FormFacade::label($label); } $html .= FormFacade::file($name, $attrs) . $errorMessage; $html .= $img; $html = sprintf($this->htmlItemTemplate, $html); return $html; }
public function build() { $this->path = $this->parseString($this->path); $this->web_path = $this->parseString($this->web_path); $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = nl2br(htmlspecialchars($this->value)); } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": if ($this->old_value) { $output .= '<div class="clearfix">'; $output .= link_to($this->web_path . $this->value, $this->value) . " "; $output .= Form::checkbox($this->name . '_remove', 1, (bool) Input::get($this->name . '_remove')) . " " . trans('rapyd::rapyd.delete') . " <br/>\n"; $output .= '</div>'; } $output .= Form::file($this->name, $this->attributes); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }