Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $value = $this->getValue();
     $label = $this->getLabel();
     $cssClass = 'ckeditor dynamic-editor';
     $errorMessage = '';
     $attrs['id'] = $id;
     if (!$this->isValid) {
         $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage());
         $cssClass .= ' error';
     }
     $defaultValue = $this->getOption('default_value');
     if (!strlen($value)) {
         $value = $defaultValue;
     }
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     $attrs['rows'] = 4;
     if ($this->getOption('rows')) {
         $attrs['rows'] = $this->getOption('rows');
     }
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= FormFacade::textarea($name, $value, $attrs) . $errorMessage;
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
Esempio n. 3
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $label = $this->getLabel();
     $cssClass = 'file';
     $attrs['id'] = $id;
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     $value = $this->value;
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= view('dynamicfield::admin.dynamicfield.media-link', compact('name', 'id', 'value'))->render();
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
Esempio n. 4
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $value = $this->getValue();
     $label = $this->getLabel();
     $cssClass = 'number form-control';
     $errorMessage = '';
     $attrs['id'] = $id;
     if (!$this->isValid) {
         $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage());
         $cssClass .= ' error';
     }
     $defaultValue = $this->getOption('default_value');
     if (!strlen($value)) {
         $value = $defaultValue;
     }
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     if ($this->getOption('placeholder')) {
         $attrs['placeholder'] = $this->getOption('placeholder');
     }
     if ($this->getOption('min_value')) {
         $attrs['min'] = $this->getOption('min_value');
     }
     if ($this->getOption('max_value')) {
         $attrs['max'] = $this->getOption('max_value');
     }
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= FormFacade::number($name, $value, $attrs) . $errorMessage;
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
Esempio n. 5
0
 */
Form::macro('radioSwitch', function ($name, $values = null, $checked = null, $options = array()) {
    if (is_null($values)) {
        $values = [1 => transpine('helpers.yes'), 0 => transpine('helpers.no')];
        $checked = is_null($checked) ? null : (int) $checked;
    }
    if (is_null($checked)) {
        $checked = array_keys($values)[0];
    }
    $html = '<p class="field switch">';
    foreach ($values as $value => $label) {
        $options['id'] = $name . $value . microtime();
        $html .= Form::radio($name, $value, $checked === $value, $options);
        $labelClass = $value == 0 ? 'cb-disable' : 'cb-enable';
        $labelClass .= $checked === $value ? ' selected' : '';
        $html .= Form::label($options['id'], $label, ['class' => $labelClass]);
    }
    $html .= '</p>';
    return $html;
});
/**
 * Create a checkbox input field with forced zero value for unchecked.
 *
 * @param  string  $name
 * @param  mixed   $value
 * @param  bool    $checked
 * @param  array   $options
 * @return string
 */
Form::macro('checkboxForced', function ($name, $value = 1, $checked = null, $options = array()) {
    return Form::hidden($name, 0) . Form::checkbox($name, $value, $checked, $options);