2.0.0
ℹ️ 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.