PHPackages                             mpospiech/doctrine-forms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. mpospiech/doctrine-forms

ActiveLibrary[Database &amp; ORM](/categories/database)

mpospiech/doctrine-forms
========================

v1.1.3(6y ago)1111GPL-2.0PHPPHP &gt;= 7.1

Since Mar 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/michalpospiech/doctrine-forms)[ Packagist](https://packagist.org/packages/mpospiech/doctrine-forms)[ RSS](/packages/mpospiech-doctrine-forms/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (7)Versions (6)Used By (0)

Doctrine Forms
==============

[](#doctrine-forms)

Instalace
---------

[](#instalace)

```
$ composer require mpospiech/doctrine-forms
```

Použití
-------

[](#použití)

Každý formulář musí být zaregistrován jako služba.

```
services:
	- App\Forms\BaseFormFactory
	- App\Forms\BaseFormChangeValuesFactory
	- App\Forms\BaseFormWithTemplateFactory
```

### Vytvoření komponenty formuláře v presenteru

[](#vytvoření-komponenty-formuláře-v-presenteru)

```
class FormPresenter extends \Nette\Application\UI\Presenter {
	/** @var BaseFormFactory @inject */
    public $baseFormFactory;

    /** @var DoctrineEntity */
    private $currentEntity; // pokud se ma jednat o update

    public function createComponentBaseForm() {
    	$component = $this->baseFormFactory->create(DoctrineEntity::class, ($this->currentEntity ? $this->currentEntity->id : 0));

        $self = $this;
        $component->addAfterSuccess(function() use ($self) {
        	$self->redirect('this');
        });

        $form = $component->getForm();

        $form->onSuccess[] = function(\Nette\Forms\Form $form, \Nette\Utils\ArrayHash $values) use ($self) {
        	if ($values->id) {
            	$self->flashMessage('Hodnoty formuláře byly úspěšně upraveny.', 'success');
            } else {
            	$self->flashMessage('Hodnoty z formuláře byly úspěšně uloženy.', 'success');
            }
        };

        return $form;
    }
}
```

### Základní formulář

[](#základní-formulář)

```
class BaseFormFactory extends \mpospiech\Doctrine\Forms\FormFactory {
	public function setupForm(\Nette\Forms\Form $form) {
    	$form->addText('name', 'Název'); // pokud neni null v databazi, tak bude nastaven jako required

        $form->addTextArea('description', 'Popis');

        $form->addText('date', 'Datum')
        	->setAttribute('placeholder', 'dd.mm.YYYY');
    }
}
```

### Formulář se změnou hodnot před uložením

[](#formulář-se-změnou-hodnot-před-uložením)

```
class BaseFormChangeValuesFactory extends \mpospiech\Doctrine\Forms\FormFactory {
	public function setupForm(\Nette\Forms\Form $form) {
    	$form->addText('name', 'Název'); // pokud neni null v databazi, tak bude nastaven jako required

        $form->addTextArea('description', 'Popis');

        $form->addText('date', 'Datum');

        $this->onBeforeSuccess[] = [$this, 'change'];
    }

    public function change(\Nette\Utils\ArrayHash $values) {
    	$values->date = \Nette\Utils\DateTime::createFromFormat('d.m.Y', $values->date); // do entity pro hodnotu date bude nyni odeslana instance DateTime
    }
}
```

### Formulář s individuální šablonou

[](#formulář-s-individuální-šablonou)

```
class BaseFormWithTemplateFactory extends \mpospiech\Doctrine\Forms\FormFactory {
	public function __construct(\Kdyby\Doctrine\EntityManager $entityManager, \Nette\Application\UI\ITemplateFactory $templateFactory)
	{
		parent::__construct($entityManager, $templateFactory);

		$this->setTemplate(__DIR__ . '/baseForm.latte', ['variable' => 'valueVariable']);
	}

	public function setupForm(\Nette\Forms\Form $form) {
    	$form->addText('name', 'Název'); // pokud neni null v databazi, tak bude nastaven jako required

        $form->addTextArea('description', 'Popis');

        $form->addText('date', 'Datum')
        	->setAttribute('placeholder', 'dd.mm.YYYY');
    }
}
```

#### Šablona

[](#šablona)

```
{form $form}

		{label name /}

		{label description /}

		{label date /}

{/form}
```

### Rozšířené nastavení formuláře

[](#rozšířené-nastavení-formuláře)

#### Nastavování jednotlivých formulářových komponent

[](#nastavování-jednotlivých-formulářových-komponent)

```
// vypnute uložení hodnoty do databáze
$form->addText('name', 'nameValue')
    ->setOption('autoSet', false);

// vypnuté nastavení výchozí hodnoty
$form->addText('name', 'nameValue')
    ->setOption('setDefaultValue', false);
```

###  Health Score

28

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~145 days

Total

5

Last Release

2338d ago

PHP version history (2 changes)v1.0.0PHP &gt;= 5.4

v1.1.3PHP &gt;= 7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/92a9b0fb505fe614e71dc192f731277196cc13bcd897d68e5e6dab15ce096fd6?d=identicon)[michal-pospiech](/maintainers/michal-pospiech)

---

Top Contributors

[![michalpospiech](https://avatars.githubusercontent.com/u/4583161?v=4)](https://github.com/michalpospiech "michalpospiech (22 commits)")

---

Tags

nettedoctrineForms

### Embed Badge

![Health badge](/badges/mpospiech-doctrine-forms/health.svg)

```
[![Health](https://phpackages.com/badges/mpospiech-doctrine-forms/health.svg)](https://phpackages.com/packages/mpospiech-doctrine-forms)
```

###  Alternatives

[kdyby/doctrine

Doctrine integration into Nette Framework

1091.0M83](/packages/kdyby-doctrine)[kdyby/doctrine-cache

Doctrine Cache bridge for Nette Framework

101.3M16](/packages/kdyby-doctrine-cache)[kdyby/annotations

Doctrine Annotations integration into Nette Framework

101.3M16](/packages/kdyby-annotations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
