Created
February 8, 2015 02:16
-
-
Save bcho/b9f0e7fafc8ff3a85a9b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| use Widget\Form; | |
| use Widget\Checkbox; | |
| class ProductPresenter { | |
| protected $resource; | |
| public function withProduct($product) | |
| { | |
| $this->resource = $product; | |
| return $this; | |
| } | |
| /** | |
| * @return string | |
| */ | |
| public function render() | |
| { | |
| return $this->renderForm(); | |
| } | |
| /** | |
| * @return string | |
| */ | |
| protected function renderForm() | |
| { | |
| $checkbox = new Checkbox(); | |
| $checkbox->setOptions([ | |
| 1 => 'Category 1', | |
| 2 => 'Category 2' | |
| ]); | |
| // $checkbox->setValue(...) | |
| return (new Form($this->resource)) | |
| ->attributes(['class' => 'product-form']) | |
| ->action('/product', ['method' => 'post']) | |
| ->add('name', 'text') // sub-widget | |
| ->add('image', 'file') // sub-widget | |
| ->add('category', $checkbox) | |
| ->add('submit', 'submit') | |
| ->render(); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI @cnsaturn