form improvements
This commit is contained in:
@@ -5,23 +5,48 @@ namespace App\View;
|
||||
|
||||
class WidgetFactory
|
||||
{
|
||||
private $labelCols = 3, $fieldCols = 8;
|
||||
|
||||
/** Configure layout used for future elements */
|
||||
public function setLayout($labelCols, $fieldCols)
|
||||
{
|
||||
$this->labelCols = $labelCols;
|
||||
$this->fieldCols = $fieldCols;
|
||||
}
|
||||
|
||||
private function baseWidget($view, $name, $label)
|
||||
{
|
||||
return (new Widget($view, $name, $label))->layout($this->labelCols, $this->fieldCols);
|
||||
}
|
||||
|
||||
public function text($name, $label)
|
||||
{
|
||||
return new Widget('input', $name, $label);
|
||||
return $this->baseWidget('input', $name, $label);
|
||||
}
|
||||
|
||||
public function password($name, $label)
|
||||
{
|
||||
return $this->baseWidget('input', $name, $label)->type('password');
|
||||
}
|
||||
|
||||
public function number($name, $label)
|
||||
{
|
||||
return new Widget('number', $name, $label);
|
||||
return $this->baseWidget('input', $name, $label)->type('number');
|
||||
}
|
||||
|
||||
public function email($name, $label)
|
||||
{
|
||||
return new Widget('email', $name, $label);
|
||||
return $this->baseWidget('input', $name, $label)->type('email');
|
||||
}
|
||||
|
||||
public function checkbox($name, $label)
|
||||
{
|
||||
return (new CheckboxWidget('checkbox', $name, $label))
|
||||
->layout($this->labelCols, $this->fieldCols);
|
||||
}
|
||||
|
||||
public function textarea($name, $label)
|
||||
{
|
||||
return (new Widget('textarea', $name, $label))->minHeight('4em');
|
||||
return $this->baseWidget('textarea', $name, $label)->minHeight('4em');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user