Base form component for Nepttune

v5.1 2019-01-17 23:47 UTC


🅱️ Base form component for Nepttune

Packagist Packagist CommitsSinceTag

Code Climate Scrutinizer Code Quality


This package introduces base form component with commonly used functionality.

  • Overriden render() method selects template which renders form subcomponent.
  • Precreated createComponentForm method creates and sets up form instance based on class constants. It also sets translator and csrf protection. Inherited class is required to implement modifyForm method where you add custom inputs to your form.
  • Package also inludes some extra validators.
    • Static validator SAME_LENGTH checks wherether two input's value is of same length.
    • Non static validator UNIQUE makes DB select and checks wherether the value is unique.
    • Regex pattern for phone number validaton.


How to use

  • Inherit from \Nepttune\Component\BaseFormComponent.
  • Inject repository class.
  • Override class contants, which define how your list is set up.
    • SAVE_NEXT [bool] (default false) defines whether the save-next button should be included in form.
    • SAVE_LIST [array] (default false) defines whether the save-list button should be included in form.
  • Implement the modifyForm method, where you add other inputs to your form.
  • If needed, override any of the methods to achieve desired behavior.
  • Validators are also defined in class constants $input->addRule(static::VALIDATOR_UNIQUE, static::VALIDATOR_UNIQUE_MSG);.