Code Monkey home page Code Monkey logo

custominputfielddependencies's Introduction

Custom Inputfield Dependencies

A module for ProcessWire CMS/CMF. Extends inputfield dependencies so that inputfield visibility or required status may be determined at runtime by selector or custom PHP code.

Overview

Custom Inputfield Dependencies adds several new settings options to the "Input" tab of "Edit Field". These are described below.

Note that the visibility or required status of fields determined by the module is calculated once at the time Page Edit loads. If your dependency settings refer to fields in the page being edited then changes will not be recalculated until the page is saved and Page Edit reloaded.

Usage

Install the Custom Inputfield Dependencies module.

Optional: for nice code highlighting of custom PHP install InputfieldAceExtended v1.2.0 or newer (currently available on the 'dev' branch of the GitHub repo).

The custom inputfield dependencies are set on the "Input" tab of "Edit Field".

'Visibility' settings

'Required' settings

Visibility

Show only if page is matched by custom find

Use InputfieldSelector to create a $pages->find() query. If the edited page is matched by the selector then the field is shown.

Custom find settings

Show only if page is matched by selector

As above, but the selector string may be entered manually.

Selector string settings

Show only if custom PHP returns true

Enter custom PHP/API code โ€“ if the statement returns boolean true then the field is shown. $page and $pages are available as local variables โ€“ other API variables may be accessed with $this, e.g. $this->config

Custom PHP settings

In most cases $page refers to the page being edited, but note that if the field is inside a repeater then $page will be the repeater page. As there could conceivably be cases where you want to use the repeater page in your custom PHP the module does not forcibly set $page to be the edited page. Instead, a helper function getEditedPage($page) is available if you want to get the edited page regardless of if the field in inside a repeater or not.

$edited_page = $this->getEditedPage($page);

Required

The settings inputfields are the same as for Visibility above, but are used to determine if the field has 'required' status on the page being edited.

License

Released under Mozilla Public License v2. See file LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.