Skip to main content
Code Tutorial

How Conditional Fields Can Clean Up Your Admin

Delight a client with a refined WordPress admin experience, and they will come back to you for more work and rev your referral engine. But, too often, admin pages are cluttered with numerous custom fields. Users get lost, confused, 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 only show themselves 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 - 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);

Access More TypeRocket

Join our community mailing list and get notified before anyone else. Get videos and more.

By using our website you agree to our Cookie policy.