Former\Traits\Field::__construct PHP Method

__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
    public function __construct(Container $app, $type, $name, $label, $value, $attributes)
    {
        // Set base parameters
        $this->app = $app;
        $this->type = $type;
        $this->value = $value;
        $this->setAttributes($attributes);
        $this->form = $this->app->bound('former.form') ? $this->app['former.form'] : null;
        // Compute and translate label
        $this->automaticLabels($name, $label);
        // Repopulate field
        if ($type != 'password' && $name !== '_token') {
            $this->value = $this->repopulate();
        }
        // Apply Live validation rules
        if ($this->app['former']->getOption('live_validation')) {
            $rules = new LiveValidation($this);
            $rules->apply($this->getRules());
        }
        // Bind the Group class
        $groupClass = $this->isCheckable() ? 'CheckableGroup' : 'Group';
        $groupClass = Former::FORMSPACE . $groupClass;
        $this->group = new $groupClass($this->app, $this->label);
    }

Usage Example

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);
     }
 }
All Usage Examples Of Former\Traits\Field::__construct