PHP code example of nepada / birth-number-input

1. Go to this page and download the library: Download nepada/birth-number-input library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nepada / birth-number-input example snippets



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;

}


$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