dev-master
9999999-devBecause Drupal Forms blow.
GPLv2
The Requires
Because Drupal Forms blow.
A slightly less hateful implementation of form handling for Drupal 7., (*1)
Because we all know drupal forms blow., (*2)
Support many form field types: * Button * File * Group * Hidden * Input * Radios * Select * Textarea * Date * Ranges (thanks Jason!) * Multiple selection Radios * Switches (Jason again), (*3)
Bonus features: * Data Tables. * Labels, (*4)
Example with validators:, (*5)
$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();
Because Drupal Forms blow.
GPLv2