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...