This repository has been archived by the owner on Feb 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #23 - Refactored inputGroup as element
- Loading branch information
1 parent
ce98b60
commit c4190c4
Showing
7 changed files
with
96 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
<?php namespace AdamWathan\BootForms\Elements; | ||
|
||
use AdamWathan\Form\Elements\Element; | ||
use AdamWathan\BootForms\Elements\FormGroup; | ||
use AdamWathan\Form\Elements\Text; | ||
|
||
class InputGroup extends Element | ||
class InputGroup extends Text | ||
{ | ||
private $formGroup; | ||
private $beforeAddon = array(); | ||
private $afterAddon = array(); | ||
protected $beforeAddon = array(); | ||
|
||
public function __construct(FormGroup $formGroup, $class = '') | ||
{ | ||
$this->formGroup = $formGroup; | ||
$this->addClass('input-group'); | ||
if (!empty($class)) $this->addClass($class); | ||
} | ||
protected $afterAddon = array(); | ||
|
||
public function beforeAddon($addon) | ||
{ | ||
$this->beforeAddon[] = $addon; | ||
return $this->formGroup; | ||
} | ||
public function beforeAddon($addon) | ||
{ | ||
$this->beforeAddon[] = $addon; | ||
|
||
return $this; | ||
} | ||
|
||
public function afterAddon($addon) | ||
{ | ||
$this->afterAddon[] = $addon; | ||
|
||
public function afterAddon($addon) | ||
return $this; | ||
} | ||
|
||
public function type($type) | ||
{ | ||
$this->afterAddon[] = $addon; | ||
return $this->formGroup; | ||
$this->attributes['type'] = $type; | ||
return $this; | ||
} | ||
|
||
protected function renderAddons($addons) | ||
{ | ||
$html = ''; | ||
foreach ($addons as $addon) { | ||
$html .= '<span class="input-group-addon">'; | ||
$html .= $addon; | ||
$html .= '</span>'; | ||
} | ||
protected function renderAddons($addons) | ||
{ | ||
$html = ''; | ||
|
||
return $html; | ||
} | ||
foreach ($addons as $addon) | ||
{ | ||
$html .= '<span class="input-group-addon">'; | ||
$html .= $addon; | ||
$html .= '</span>'; | ||
} | ||
|
||
return $html; | ||
} | ||
|
||
public function render() | ||
{ | ||
$html = '<div'; | ||
$html .= $this->renderAttributes(); | ||
$html .= '>'; | ||
$html = '<div class="input-group">'; | ||
$html .= $this->renderAddons($this->beforeAddon); | ||
$html .= $this->formGroup->control(); | ||
$html .= parent::render(); | ||
$html .= $this->renderAddons($this->afterAddon); | ||
$html .= '</div>'; | ||
|
||
return $html; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters