Jump to content

RockOptionsApi - easy manipulation of option-fields via API


bernhard
 Share

Recommended Posts

Have you ever had a hard time setting the values of an options field via API? Grab RockOptionsAPIĀ šŸ˜Ž

https://github.com/baumrock/RockOptionsApi

RockOptionsApi

ProcessWire module for easy manipulation of option-fields via API

$page->getOptions('yourfield')
  ->add('foo')
  ->remove('bar')
  ->save();

optionsapi.gif

Readonly options field renderer

By default options fields that are set to readonly via theĀ lockedĀ collapse state only show selected options and hide other available options. That might not be what you want. Here is an alternative that turns this:

write.png

Into that:

read.png

Simply callĀ $form->readonlyOptions('yourfield')Ā in the ProcessPageEdit::buildForm hook or when using MagicPages in theĀ editForm()Ā method:

$wire->addHookAfter("ProcessPageEdit::buildForm", function($event) {
  $form = $event->return;
  $form->readonlyOptions('yourfield');
});
  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
Ɨ
Ɨ
  • Create New...