__construct() public method

Set up a Field instance
public __construct ( Illuminate\Container\Container $app, string $type, $name, $label, $value, $attributes )
$app Illuminate\Container\Container
$type string A field type
Example #1
0
 /**
  * Build a new checkable
  */
 public function __construct(Container $app, $type, $name, $label, $value, $attributes)
 {
     parent::__construct($app, $type, $name, $label, $value, $attributes);
     if (is_array($this->value)) {
         $this->items($this->value);
     }
 }
Example #2
0
 /**
  * Easier arguments order for hidden fields
  *
  * @param Container $app        The Illuminate Container
  * @param string    $type       file
  * @param string    $name       Field name
  * @param string    $label      Its label
  * @param string    $value      Its value
  * @param array     $attributes Attributes
  */
 public function __construct(Container $app, $type, $name, $label, $value, $attributes)
 {
     // Multiple files field
     if ($type == 'files') {
         $attributes['multiple'] = 'true';
         $type = 'file';
         $name = $name . '[]';
     }
     parent::__construct($app, $type, $name, $label, $value, $attributes);
 }
Example #3
0
 /**
  * Build a new checkable
  *
  * @param Container $app
  * @param string    $type
  * @param array     $name
  * @param           $label
  * @param           $value
  * @param           $attributes
  */
 public function __construct(Container $app, $type, $name, $label, $value, $attributes)
 {
     // Unify auto and chained methods of grouping checkboxes
     if (ends_with($name, '[]')) {
         $name = substr($name, 0, -2);
         $this->grouped();
     }
     parent::__construct($app, $type, $name, $label, $value, $attributes);
     if (is_array($this->value)) {
         $this->items($this->value);
     }
 }
Example #4
0
 /**
  * Build an input field
  *
  * @param Container $app        The Container
  * @param string    $type       The input type
  * @param string    $name       Field name
  * @param string    $label      Its label
  * @param string    $value      Its value
  * @param array     $attributes Attributes
  */
 public function __construct(Container $app, $type, $name, $label, $value, $attributes)
 {
     parent::__construct($app, $type, $name, $label, $value, $attributes);
     // Multiple models population
     if (is_array($this->value)) {
         $values = array();
         foreach ($this->value as $value) {
             $values[] = is_object($value) ? $value->__toString() : $value;
         }
         if (isset($values)) {
             $this->value = implode(', ', $values);
         }
     }
 }
Example #5
0
 /**
  * Easier arguments order for selects
  *
  * @param Container $app        The Container instance
  * @param string    $type       select
  * @param string    $name       Field name
  * @param string    $label      Its label
  * @param array     $options    The select's options
  * @param string    $selected   The selected option
  * @param array     $attributes Attributes
  */
 public function __construct(Container $app, $type, $name, $label, $options, $selected, $attributes)
 {
     if ($selected) {
         $this->value = $selected;
     }
     if ($options) {
         $this->options($options);
     }
     parent::__construct($app, $type, $name, $label, $selected, $attributes);
     // Nested models population
     if (str_contains($this->name, '.') and is_array($this->value) and !empty($this->value) and is_string($this->value[key($this->value)])) {
         $this->fromQuery($this->value);
         $this->value = $selected ?: null;
     }
 }
Example #6
0
 /**
  * Encore text type
  *
  * @param Container $app
  * @param strign    $type
  * @param string    $name
  * @param string    $label
  * @param string    $value
  * @param array     $attributes
  */
 public function __construct(Container $app, $type, $name, $label, $value, $attributes)
 {
     parent::__construct($app, $type, $name, $label, $value, $attributes);
     $this->type = 'text';
 }
Example #7
0
 /**
  * Easier arguments order for hidden fields
  *
  * @param Container $app        The Container
  * @param string    $type       hidden
  * @param string    $name       Field names
  * @param string    $value      Its value
  * @param array     $attributes Attributes
  */
 public function __construct(Container $app, $type, $name, $value, $attributes)
 {
     parent::__construct($app, $type, $name, '', $value, $attributes);
 }