PHPackages                             matthewbaggett/drupal\_magic\_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. [Utility &amp; Helpers](/categories/utility)
4. /
5. matthewbaggett/drupal\_magic\_forms

ActiveDrupal-module[Utility &amp; Helpers](/categories/utility)

matthewbaggett/drupal\_magic\_forms
===================================

Because Drupal Forms blow.

0121[2 issues](https://github.com/matthewbaggett/drupal_magic_forms/issues)PHP

Since Feb 6Pushed 10y ago3 watchersCompare

[ Source](https://github.com/matthewbaggett/drupal_magic_forms)[ Packagist](https://packagist.org/packages/matthewbaggett/drupal_magic_forms)[ RSS](/packages/matthewbaggett-drupal-magic-forms/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Magic Form Objects
==================

[](#magic-form-objects)

A slightly less hateful implementation of form handling for Drupal 7.

Because we all know drupal forms blow.

Support many form field types:

- Button
- File
- Group
- Hidden
- Input
- Radios
- Select
- Textarea
- Date
- Ranges (thanks Jason!)
- Multiple selection Radios
- Switches (Jason again)

Bonus features:

- Data Tables.
- Labels

Validators
==========

[](#validators)

Example with validators:

```
$form = new magic_form('my-form');
$form
  ->add_field(
    magic_form_field_text::factory('some-field', 'Some Field', 'Some Default')
      ->add_validator(new magic_form_validator_is_valid_phonenumber())
      ->add_validator(new magic_form_validator_is_valid_email())
  )->add_field(
    magic_form_field_text::factory('other-field')
      ->add_validator(new magic_form_validator_is_less_than(100))
      ->add_validator(new magic_form_validator_is_greater_than(50))
  )->add_field(
    magic_form_field_text::factory('other-field')
      ->add_validators(
        new magic_form_validator_is_less_than(100),
        new magic_form_validator_is_greater_than(50),
        new magic_form_validator_regexp('REGEXP_GOES_HERE')
      )
  )->add_fields(
    magic_form_field_text::factory('some-field', 'Some Field', 'Some Default')
      ->add_validator(new magic_form_validator_is_valid_phonenumber())
      ->add_validator(new magic_form_validator_is_valid_email()),
    magic_form_field_text::factory('some-field', 'Some Field', 'Some Default')
      ->add_validator(new magic_form_validator_is_valid_phonenumber())
      ->add_validator(new magic_form_validator_is_valid_email()),
    magic_form_field_text::factory('some-field', 'Some Field', 'Some Default')
      ->add_validator(new magic_form_validator_is_valid_phonenumber())
      ->add_validator(new magic_form_validator_is_valid_email()),
    magic_form_field_text::factory('some-field', 'Some Field', 'Some Default')
      ->add_validator(new magic_form_validator_is_valid_phonenumber())
      ->add_validator(new magic_form_validator_is_valid_email())
  );

  $form->submit(function (magic_form $form) {
      drupal_set_message("Submit happened in form {$form->magic_form_id} / {$form->form_id}");
  });

  // Check to see if an earlier, updated build of this form exists.
  magic_form::check_for_updated_form($form);

  // render the form.
  return $form->__toString();

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5707be384b9daab9858223c5dfead9d692e8b5f6afa8dd23ad5c5cbc149316b2?d=identicon)[matthewbaggett](/maintainers/matthewbaggett)

---

Top Contributors

[![matthewbaggett](https://avatars.githubusercontent.com/u/943948?v=4)](https://github.com/matthewbaggett "matthewbaggett (130 commits)")

### Embed Badge

![Health badge](/badges/matthewbaggett-drupal-magic-forms/health.svg)

```
[![Health](https://phpackages.com/badges/matthewbaggett-drupal-magic-forms/health.svg)](https://phpackages.com/packages/matthewbaggett-drupal-magic-forms)
```

###  Alternatives

[ramsey/coding-standard

A common coding standard for Ramsey's PHP libraries.

1091.1k36](/packages/ramsey-coding-standard)

PHPackages © 2026

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