-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f8f094
commit aaae6e2
Showing
2 changed files
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* This file is part of the Clastic package. | ||
* | ||
* (c) Dries De Peuter <dries@nousefreak.be> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Clastic\BackofficeBundle\Form; | ||
|
||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
/** | ||
* TabHelper | ||
* | ||
* @author Dries De Peuter <dries@nousefreak.be> | ||
*/ | ||
class TabHelper | ||
{ | ||
/** | ||
* @var FormBuilderInterface | ||
*/ | ||
private $formBuilder; | ||
|
||
/** | ||
* @param FormBuilderInterface $formBuilder | ||
*/ | ||
public function __construct(FormBuilderInterface $formBuilder) | ||
{ | ||
$this->formBuilder = $formBuilder; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* | ||
* @return FormBuilderInterface | ||
*/ | ||
public function findTab($name) | ||
{ | ||
return $this->formBuilder->get('tabs')->get($name); | ||
} | ||
|
||
/** | ||
* Create a new tab and nest it under the tabs. | ||
* | ||
* @param string $name | ||
* @param string $label | ||
* @param array $options | ||
* | ||
* @return FormBuilderInterface The created tab. | ||
*/ | ||
public function createTab($name, $label, $options = array()) | ||
{ | ||
$options = array_replace( | ||
$options, | ||
array( | ||
'label' => $label, | ||
'inherit_data' => true, | ||
)); | ||
|
||
$tab = $this->formBuilder->create($name, 'tabs_tab', $options); | ||
$this->formBuilder->get('tabs')->add($tab); | ||
|
||
return $tab; | ||
} | ||
} |
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