Back to Skills

nette-forms

verified

Invoke before creating or modifying Nette Forms. Provides form controls, validation, rendering patterns.

View on GitHub

Marketplace

nette

nette/claude-code

Plugin

nette

development

Repository
Verified Org

nette/claude-code
29stars

plugins/nette/skills/nette-forms/SKILL.md

Last Verified

January 20, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/nette/claude-code/blob/main/plugins/nette/skills/nette-forms/SKILL.md -a claude-code --skill nette-forms

Installation paths:

Claude
.claude/skills/nette-forms/
Powered by add-skill CLI

Instructions

## Nette Forms

Nette Forms provides secure, reusable forms with automatic validation on both client and server side.

```shell
composer require nette/forms
```

### Forms in Presenters

Forms are created in factory methods named `createComponent<Name>`:

```php
protected function createComponentRegistrationForm(): Form
{
	$form = new Form;
	$form->addText('name', 'Name:')
		->setRequired('Please enter your name.');

	$form->addEmail('email', 'Email:')
		->setRequired('Please enter your email.');

	$form->addPassword('password', 'Password:')
		->setRequired('Please enter password.')
		->addRule($form::MinLength, 'Password must be at least %d characters', 8);

	$form->addSubmit('send', 'Register');

	$form->onSuccess[] = $this->registrationFormSucceeded(...);
	return $form;
}

private function registrationFormSucceeded(Form $form, \stdClass $data): void
{
	// $data->name, $data->email, $data->password
	$this->flashMessage('Registration successful.');
	$this->redirect('Home:');
}
```

Render in template:

```latte
{control registrationForm}
```

### Create and Edit Pattern

Unified form for both creating and editing records:

```php
class ProductPresenter extends BasePresenter
{
	public function __construct(
		private ProductFacade $facade,
	) {}

	public function renderEdit(int $id = null): void
	{
		$this->template->product = $id
			? $this->facade->getProduct($id)
			: null;
	}

	protected function createComponentProductForm(): Form
	{
		$form = new Form;
		$form->addText('name', 'Name:')
			->setRequired();
		$form->addTextArea('description', 'Description:');
		$form->addInteger('price', 'Price:')
			->setRequired()
			->addRule($form::Min, 'Price must be positive', 1);
		$form->addSubmit('send', 'Save');
		$form->onSuccess[] = $this->productFormSucceeded(...);
		return $form;
	}

	private function productFormSucceeded(Form $form, \stdClass $data): void
	{
		$id = $this->getParameter('id');
		if ($id) {
			$this->facade->update($id, (array) $data);
			$this->flash

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
7569 chars