wp-fields

ChriCo Fields is a Composer package (not a plugin) that allows to generate form fields in WordPress.

GPL-3.0 License

Downloads
60.7K
Stars
19
Committers
6

Bot releases are hidden (Show)

wp-fields - 2.3.2 Latest Release

Published by Chrico about 1 year ago

Element

  • fix Element::attributesForView() to return correct "disabled"-state in case the parent is disabled.

View/FormRow

  • add new selector "form-row--is-disabled".

View/Form

  • remove "value" from being rendered as <form>-attribute
wp-fields - 2.3.1

Published by Chrico about 1 year ago

Improvements on Form

  • Don't submit any data in case the Form is disabled.
  • Don't allow re-submit of submitted forms.
  • Allow inserting $inputData where the Form::name() is within that collection.
  • Set "submitted"-state in Form::submit() after $inputData is assigned to Elements.
wp-fields - 2.3.0

Published by Chrico about 1 year ago

Element

  • Introduce new methods Element::withParent() and Element::parent() to keep track of the parent CollectionElement/Form and track "submission"-state on all Elements.
  • Introduced new method which prepares the "id" and "name" for rendering to take the Element parents into account.

Form, CollectionElement, Element

Reduced amount of methods which are overwritten and ensure that with*() methods are not callable after submission.

wp-fields - 2.2.0

Published by Chrico about 1 year ago

Improvements

  • Element // ensure that withOptions() calls internally withOption().
  • Element // ensure that withAttributes() calls internally withAttribute().

Testing

  • ElementFactoryTest // removes randomness from test cases.
  • workflows/php-qa.yml // execute all steps in parallel.
  • Add output for phpunit.
wp-fields - 2.1.5

Published by Chrico about 1 year ago

Form

Fixing bug where non-existing fields in data array caused to overwrite existing field values (defaults) with empty values.

wp-fields - 2.1.4

Published by Chrico over 1 year ago

  • Element // improve return types by using "static" instead of the specific class or implemented interface.
wp-fields - 2.1.3

Published by Chrico over 1 year ago

  • AttributeFormatterTrait // add the Element::id() as "element" to the selector.
wp-fields - 2.1.2

Published by Chrico over 1 year ago

  • Checkbox/Radio // no escaping for choice labels. It can be possible that those labels actually have HTML in text.
wp-fields - 2.1.1

Published by Chrico over 1 year ago

  • Form // fix handling of isValid when the Form has errors. Add missing method mock in FormTest::testIsValid().
wp-fields - 2.1.0

Published by Chrico over 1 year ago

ChoiceList

Refactor internal structure to support "disabled"-attribute for checkbox, radio and options and allow in future to add more settings like "help"-text.

View

Complete refactor of markup to move away from <table> and be more flexible with styling elements. All elements on output will now have the "type" as modifier on the wrapper. Additionally the <label> and Element itself will now also have a CSS class including the type.

View/Button

Introduce new "reset"- and "button"-types which will render a <button>

Element

Filter- and Validator-callbacks now will get the Element itself as second parameter.

QoL

  • Cleanup variables and docBlocks.
  • Update documentation
wp-fields - 2.0.2

Published by Chrico over 1 year ago

  • CollectionElement // fix issue with CollectionElement::hasErrors() not checking if children have errors.
wp-fields - 2.0.1

Published by Chrico over 1 year ago

  • Add missing autoload.files section in composer.json to load inc/functions.php.
wp-fields - 2.0.0

Published by Chrico over 1 year ago

ℹ️ This release contains a rework of the code to drop PHP <8.0 support. The public API will stay as it is.

Removed external dependencies

Following external dependencies were removed:

Pimple

The Extensions\Provider was removed from that library. We do not need to use any Container anymore by default. You can now use directly the functions ChriCo\Fields\renderElement() in your view/template and ChriCo\Fields\createElement() in your controller, instead of the Factories.

inpsyde/validator and inpsyde/filter

ChriCo\Fields\Element\Element does not rely anymore on inspyde/validator and inpsyde/validator.
From now on, you can simply add a callable for validation which will return either null on success or WP_Error on failure and for filtering (sanitization) a callback, which returns the sanitized value.

use ChriCo\Fields\Element\Element;

$text = (new Element('my-text'))
    ->withValidator(static function(string $value): ?WP_Error {
        if(!is_email($value)){
            return new WP_Error('my-text', __('Please insert a valid E-Mail address', 'your-textdomain'));
        }
        return null;
    })
    ->withFilter(static fn($value): string => sanitize_text_field($value));

View\FormRow improvements

View\FormRow will now have CSS classes with the "type" and "name" of the rendered Element. Addtionally for ChriCo\Fields\Element\Elemen::type() === "hidden", we will automatically add the CSS class hidden to the row to avoid any whitespacing.

View\Collection improvements

The ChriCo\Fields\View\Collection will now not nest anymore table > tr > td > table for nested Collection-elements.

QoL

  • Switched from Travis to Github Workflows.
wp-fields - 1.0.1

Published by Chrico almost 3 years ago

  • Fix typo in method signature - Method name is configureEollection and should be configureCollection #5
  • update method names #6 .
  • Introduce unit tests to ensure Element get options #10
  • fix: be more flexible on composer constraints since we require this package in other packages #13

props to @widoz and @luislard

wp-fields - 1.0

Published by Chrico over 6 years ago

[1] Breaking changes

There happened a complete rewrite of API, which means we're now going to PSR-2 code style instead of using the underscore methodes from WordPress.

Removing set_*

All set_ -methods are now with-methods in camelCase. So e.G. set_value is now withValue and also are now returning the object to allow chaining.

Removing get_

All get_-methods are now without this prefix. So e.G. get_value is now just value, which is way more intuitive.

BaseElement removed
The Element\BaseElement was removed and completly migrated into Element\Element.

Collection add multiple Element
The method add_elements is removed. To add multiple Element-instances you can either use:

// v1 - chaining
$collection
	->withElement($element1)
	->withElement($element2);
	
// v2 - without chaining
$collection->withElement($element1, $element2);

// v3 - when having elements in an array
$collection->withElement(...[$element1, $element2]);
wp-fields - 0.3.0

Published by Chrico almost 7 years ago

Added

  • Introduced new view-class View\Description to render the description output.
  • Added wp-coding-standards/wpcs and automatic code style test via travis-ci.
  • Form::bind_data is now deprecated and will be removed by Form::submit in future.
  • Calling Form::submit will now set a new state "is_submitted = TRUE".
  • Added new method Form::is_submitted.

Improvements

  • Several smaller improvements in View\FormRow.
  • View\Form now checks for Element\FormInterface instead of Element\Form.
  • Form::submit will now automatically trigger validation of elements and binding errors.
  • Moved documentation into docs/-folder and splitted it into multiple files.
wp-fields - First Release.

Published by Chrico over 7 years ago

Package Rankings
Top 10.16% on Packagist.org
Badges
Extracted from project README
Latest Stable Version Project Status Unit tests PHP License
Related Projects