Skip to content

Commit

Permalink
Polished docs (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek authored Mar 12, 2021
1 parent 3690240 commit 1c79c0e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
96 changes: 48 additions & 48 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ composer require contributte/forms

ApplicationFormFactory returns instance of `Nette\Application\UI\Form`. It should be used in place of StandaloneFormFactory if [nette/application](https://github.com/nette/application) is installed.

```yaml
```neon
extensions:
forms.application: Contributte\Forms\DI\ApplicationFormFactoryExtension
forms.application: Contributte\Forms\DI\ApplicationFormFactoryExtension
```

You can override it by your implementation.

```yaml
```neon
services:
forms.application.factory: My\FormFactory
forms.application.factory: My\FormFactory
```

Straightforward way is to **inject** the factory in a presenter.
Expand All @@ -39,17 +39,17 @@ use Nette\Application\UI\Form;
final class UserPresenter extends BasePresenter
{

/** @var IApplicationFormFactory @inject */
public $factory;
/** @var IApplicationFormFactory @inject */
public $factory;

protected function createComponentUserForm(): Form
{
$form = $this->factory->create();
protected function createComponentUserForm(): Form
{
$form = $this->factory->create();

// Add inputs here!
// Add inputs here!

return $form;
}
return $form;
}

}
```
Expand All @@ -65,22 +65,22 @@ use Nette\Application\UI\Form;
final class UserFormFactory
{

/** @var IApplicationFormFactory */
private $factory;
/** @var IApplicationFormFactory */
private $factory;

public function __construct(IApplicationFormFactory $factory)
{
$this->factory = $factory;
}
public function __construct(IApplicationFormFactory $factory)
{
$this->factory = $factory;
}

public function create(): Form
{
$form = $this->factory->create();
public function create(): Form
{
$form = $this->factory->create();

// Add inputs here!
// Add inputs here!

return $form;
}
return $form;
}

}
```
Expand All @@ -89,16 +89,16 @@ final class UserFormFactory

StandaloneFormFactory returns instance of `Nette\Forms\Form`. It should be used only if [nette/application](https://github.com/nette/application) is not installed.

```yaml
```neon
extensions:
forms.standalone: Contributte\Forms\DI\StandaloneFormFactoryExtension
forms.standalone: Contributte\Forms\DI\StandaloneFormFactoryExtension
```

You can override it by your implementation.

```yaml
```neon
services:
forms.standalone.factory: My\FormFactory
forms.standalone.factory: My\FormFactory
```

Straightforward way is to **inject** factory in a presenter.
Expand All @@ -112,17 +112,17 @@ use Nette\Forms\Form;
final class UserPresenter extends BasePresenter
{

/** @var IStandaloneFormFactory @inject */
public $factory;
/** @var IStandaloneFormFactory @inject */
public $factory;

protected function createComponentUserForm(): Form
{
$form = $this->factory->create();
protected function createComponentUserForm(): Form
{
$form = $this->factory->create();

// Add inputs here!
// Add inputs here!

return $form;
}
return $form;
}

}
```
Expand All @@ -138,22 +138,22 @@ use Nette\Forms\Form;
final class UserFormFactory
{

/** @var IStandaloneFormFactory */
private $factory;
/** @var IStandaloneFormFactory */
private $factory;

public function __construct(IStandaloneFormFactory $factory)
{
$this->factory = $factory;
}
public function __construct(IStandaloneFormFactory $factory)
{
$this->factory = $factory;
}

public function create(): Form
{
$form = $this->factory->create();
public function create(): Form
{
$form = $this->factory->create();

// Add inputs here!
// Add inputs here!

return $form;
}
return $form;
}

}
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact

To install latest version of `contributte/forms` use [Composer](https://getcomposer.com).

```
```bash
composer require contributte/forms
```

Expand All @@ -48,5 +48,5 @@ See [how to contribute](https://contributte.org) to this package. This package i

-----

Consider to [support](https://contributte.com/partners) **contributte** development team.
Consider to [support](https://contributte.org/partners) **contributte** development team.
Also thank you for using this package.

0 comments on commit 1c79c0e

Please sign in to comment.