ChriCo Fields is a Composer package (not a plugin) that allows to generate form fields in WordPress.
GPL-3.0 License
Bot releases are hidden (Show)
Element
Element::attributesForView()
to return correct "disabled"-state in case the parent is disabled.View/FormRow
View/Form
<form>
-attributePublished by Chrico about 1 year ago
Form
$inputData
where the Form::name()
is within that collection.Form::submit()
after $inputData
is assigned to Elements.Published by Chrico about 1 year ago
Element::withParent()
and Element::parent()
to keep track of the parent CollectionElement
/Form
and track "submission"-state on all Elements.Reduced amount of methods which are overwritten and ensure that with*()
methods are not callable after submission.
Published by Chrico about 1 year ago
withOptions()
calls internally withOption()
.withAttributes()
calls internally withAttribute()
.Published by Chrico about 1 year ago
Fixing bug where non-existing fields in data array caused to overwrite existing field values (defaults) with empty values.
Published by Chrico over 1 year ago
Published by Chrico over 1 year ago
Element::id()
as "element" to the selector.Published by Chrico over 1 year ago
Published by Chrico over 1 year ago
Published by Chrico over 1 year ago
Refactor internal structure to support "disabled"-attribute for checkbox, radio and options and allow in future to add more settings like "help"-text.
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.
Introduce new "reset"- and "button"-types which will render a <button>
Filter- and Validator-callbacks now will get the Element itself as second parameter.
Published by Chrico over 1 year ago
Published by Chrico over 1 year ago
autoload.files
section in composer.json
to load inc/functions.php
.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.
Following external dependencies were removed:
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.
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
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.
The ChriCo\Fields\View\Collection
will now not nest anymore table > tr > td > table
for nested Collection-elements.
Published by Chrico almost 3 years ago
configureEollection
and should be configureCollection
#5props to @widoz and @luislard
Published by Chrico over 6 years ago
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]);
Published by Chrico almost 7 years ago
View\Description
to render the description output.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.Form::submit
will now set a new state "is_submitted = TRUE".Form::is_submitted
.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.docs/
-folder and splitted it into multiple files.Published by Chrico over 7 years ago