How Conditional Fields Can Win You More Work
Delight a client with a refined WordPress admin experience, and they will come back to you for more and rev your referral engine. But, too often, admin pages are cluttered with numerous custom fields, and users get lost, confusing, and frustrated. How can you build the features your clients need without sacrificing their experience and your future work? By using TypeRocket Pro's conditional fields.
Imagine an intelligent and clean admin page where custom fields hide and show themselves until the moment a client needs them. A page like this with 20 input fields might only show 3 fields at first. As the user begins to interact with the page, it intelligently shows new relevant fields and hides old inapplicable fields.
Conditional fields help you create a refined user experience by allowing you to hide select fields when they are not needed.
TypeRocket Pro makes adding powerfully intelligent conditional fields easy. And, unlike other systems, you can additionally hide and show entire sections of a form and not just individual fields.
To make a field or section conditional use the
when() method on a field or section. Here is simple example using a checkbox:
echo $form->toggle('Add Store Hours'); echo $form->section( $form->text('Mon'), $form->text('Tues'), $form->text('Wed'), $form->text('Thurs'), $form->text('Fri'), )->when('add_store_hours');
However, you can get fancy by using condisions:
echo $form->select('Number')->setOptions(['One' => 1, 'Two' => 2]); echo $form->toggle('Feature It')->when('number', '=', 1); echo $form->toggle('Feature This')->when('number', '<', 2); echo $form->toggle('Feature That')->when('number', '>', 1);