MForm facilitates the creation of REDAXO module inputs. With MForm, you can not only create forms, but also visually design them exactly to your own specifications thanks to flexible templates. It allows you to create all standard REDAXO form elements and includes several extra widgets that can be easily integrated into modules.
But it doesn’t stop there! MForm also enhances YForm and rex_form with additional widgets. Need a custom link field or a chic image list? No problem, MForm has you covered.
The highlight of the latest version? The brand-new Form Repeater! This feature replaces the old MBlock AddOn and offers the ability to not only repeat form elements but also nest them at multiple levels – something that was not possible with MBlock. This allows for the construction of even more complex forms.
The included demo collection allows for immediate testing of module codes. Modules can be directly installed and tested. The codes are all commented. And additionally, there is a comprehensive documentation 📒.
The Form Repeater allows dynamic repetition of form elements while realizing nesting at multiple levels.
The new repeater is only compatible with MBlock to a limited extent.
It does not currently work during a migration:
MBlock Module
use FriendsOfRedaxo\MForm;
// Base ID for managing form elements
$id = 1;
// Initialize MForm
$mform = new MForm();
// Add a fieldset
$mform->addFieldsetArea('Team member');
// Add a text field, referring dynamically to a JSON format
$mform->addTextField("$id.0.name", array('label' => 'Name'));
// Add a media field saved by MBlock in JSON
$mform->addMediaField(1, array('label' => 'Avatar'));
// Output the form with MBlock, which allows dynamic handling of blocks
echo MBlock::show($id, $mform->show(), array('min' => 2, 'max' => 4));
The same module in MForm 8
To determine the necessary field keys, a dump might be needed beforehand.
Note: From the original MBlock Mediafield 1, it becomes: 'REX_MEDIA_1'
use FriendsOfRedaxo\MForm;
// Repeater initialization ID with the base ID of the original MBlock section
$id = 1;
// Create a new MForm instance with the factory method and directly integrate a repeater
echo MForm::factory()
->addRepeaterElement(
$id,
MForm::factory()
->addFieldsetArea('Team member',
MForm::factory()
->addTextField('name', ['label' => 'Name'])
->addMediaField('REX_MEDIA_1', ['label' => 'Avatar'])
),
true,
true,
['min' => 2, 'max' => 4]
)
->show();
MForm can be directly installed via the Redaxo Installer. MForm Redaxo Addon Page
MForm utilizes REDAXO variables provided by REDAXO, either as classic or JSON values. For more information, see the REDAXO Documentation.
MForm is licensed under the MIT License.
See CHANGELOG.md
Friends Of REDAXO
Project Lead
2nd Maintainer
Mform Repeater
Docs & Testing