npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nepada/birth-number-input

v1.2.1

Published

Client side validation of Birth number form input for Nette forms.

Downloads

27

Readme

Czech birth number form input

Build Status Coverage Status Downloads this Month Latest stable

Installation

Via Composer:

$ composer require nepada/birth-number-input

Option A: install form container extension method via DI extension

extensions:
    - Nepada\Bridges\BirthNumberInputDI\BirthNumberInputExtension

It will register extension method addBirthNumber($name, $label = null): BirthNumberInput to Nette\Forms\Container.

Option B: use trait in your base form/container class

You can also use BirthNumberInputMixin trait in your base form/container class to add method addBirthNumber($name, $label = null): BirthNumberInput.

Example:


trait FormControls
{

    use Nepada\Bridges\BirthNumberInputForms\BirthNumberInputMixin;

    public function addContainer($name)
    {
        $control = new Container;
        $control->setCurrentGroup($this->getCurrentGroup());
        if ($this->currentGroup !== null) {
            $this->currentGroup->add($control);
        }
        return $this[$name] = $control;
    }

}

class Container extends Nette\Forms\Container
{

    use FormControls;

}

class Form extends Nette\Forms\Form
{

    use FormControls;

}

Usage

BirthNumberInput is form control that uses birth number value object to represent its value (see nepada/birth-number for further details). It automatically validates the user input and getValue() method always returns BirthNumber instance, or null if the input is not filled.

$birthNumberInput = $form->addBirthNumber('birthNumber');
$birthNumberInput->setValue('invalid'); // \InvalidArgumentException is thrown
$birthNumberInput->setValue('000101 / 0009'); // the value is internally converted to BirthNumber value object
$birthNumberInput->getValue(); // BirthNumber instance for 000101/0009

Client side validation

Using precompiled bundle

Using precompiled bundles is the quick'n'dirty way of getting client side validation to work.

<script src="https://unpkg.com/nette-forms@%5E3.0/src/assets/netteForms.min.js"></script>
<script src="https://unpkg.com/@nepada/birth-number-input@%5E1.0/dist/birth-number-input.min.js"></script>

Building your own bundle

It is highly recommended to install the client side package via nmp and compile your own bundle.

Here is an example script for initialization of birth number input and Nette forms.

import Nette from 'nette-forms';
import initializeBirthNumberInput from '@nepada/birth-number-input';

initializeBirthNumberInput(Nette);
Nette.initOnLoad();