Jump to content

Recommended Posts

Posted

Let's say I have Fieldset Group called Tables that contains 3 x Pro Fields table. Each table is label, value where label is set via the API and is readonly (see below). If I set the field to be Closed on load, how can I set it so that if in any of the tables if value is empty instead of seeing a closed fieldset:

Tables ...

I get something like:

Tables ... 7 missing values or Tables (7 missing values) ...  (either is okay)

Additional questions:

  1. I also want to hide the new row button but I think I can easily do that with CSS. Use this CSS: li#Inputfield_{myFieldName}pageText a.InputfieldTableAddRow { display: none; }
  2. How can I make the label field in the table readonly, add readonly=readonly to the settings for that column doesn't do it. Use this JS: $('input.{myFieldName}-label').attr('readonly', 'readonly').attr('onfocus', 'this.blur()').css('opacity', 0.6);
  3. How to sort the table A to Z by label Didn't realise there is a setting for this, great!

Thanks.

EDIT: Here's how I did it:

\ProcessWire\wire()->addHookAfter('ProcessPageEdit::buildForm', function(\ProcessWire\HookEvent $event) {

	$object		= $event->object;
	$form 		= $event->arguments('form');
	$page 		= $object->getPage();

	$page->of(false);

	if ($page->myField) {

		$toAction = 0;

		foreach ($page->$myField as $row) {

			if (!$row->value) {

				$toAction ++;

			}

		}

		if ($toAction > 0) {

			$form->prependMarkup('<div class="pw-container uk-container uk-container-expand"><div class="uk-alert uk-alert-danger"><span class="fa fa-exclamation-circle"></span> Check the <strong>Page text</strong> tab; ' . (int) $toAction . ' value(s) needs entering</div></div>');

		}

	}

});

 

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
  • Recently Browsing   0 members

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