{"id":15675022,"url":"https://github.com/awran5/cmb2-conditional-logic","last_synced_at":"2025-05-06T23:41:08.505Z","repository":{"id":42179627,"uuid":"130062177","full_name":"awran5/CMB2-conditional-logic","owner":"awran5","description":"A small jQuery plugin for handling conditional logic fields for CMB2.","archived":false,"fork":false,"pushed_at":"2021-07-04T15:00:21.000Z","size":22,"stargazers_count":15,"open_issues_count":6,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T04:04:50.731Z","etag":null,"topics":["cmb2","cmb2-conditionals","jquery-plugin","wordpress-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awran5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-18T12:54:55.000Z","updated_at":"2024-12-21T09:48:06.000Z","dependencies_parsed_at":"2022-09-10T01:21:01.720Z","dependency_job_id":null,"html_url":"https://github.com/awran5/CMB2-conditional-logic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awran5%2FCMB2-conditional-logic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awran5%2FCMB2-conditional-logic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awran5%2FCMB2-conditional-logic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awran5%2FCMB2-conditional-logic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awran5","download_url":"https://codeload.github.com/awran5/CMB2-conditional-logic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788376,"owners_count":21804280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmb2","cmb2-conditionals","jquery-plugin","wordpress-plugin"],"created_at":"2024-10-03T15:54:55.856Z","updated_at":"2025-05-06T23:41:08.484Z","avatar_url":"https://github.com/awran5.png","language":"JavaScript","readme":"# CMB2 conditional logic\nA small jQuery plugin for handling conditional logic fields for [CMB2](https://github.com/CMB2/CMB2).\u003cbr\u003e\nI used to use [cmb2-conditionals](https://github.com/jcchavezs/cmb2-conditionals) pluing but since it doesn't work properly on Group fields and not updated for 2 years, I decided to create a new one. The plugin currently supports checkboxes, radios and select lists.\n\n## Installation\n- If you like, you can use WordPress ready verion [here](https://github.com/awran5/WP-CMB2-conditional-logic/) or simply include the `CMB2-conditional-logic.js` file in your project using [admin_enqueue_scripts](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts)\n- Adding conditional fields is just like before, just add a new `attributes` parameters: `data-conditional-id` which should match the conditional feild ID and `data-conditional-value` which should match the conditional value\n\n#### For adding conditional fields, add a new `attributes` parameter: \n1. `data-conditional-id` which should match the conditional feild ID.\n2. `data-conditional-value` which should match the conditional value.\n3. `data-conditional-invert` use true to invert the behaviour\n\n```php\n    $cmb_demo-\u003eadd_field( array(\n        'name'          =\u003e __( 'Conditional select test:', 'your-text-domain' ),\n        'desc'          =\u003e __('some description', 'your-text-domain'),\n        'id'            =\u003e 'test_select_id',\n        'type'          =\u003e 'select',\n        'options'       =\u003e array(\n            'one'    =\u003e __('one', 'your-text-domain' ),\n            'two'    =\u003e __('two', 'your-text-domain'),\n            'three'  =\u003e __('three', 'your-text-domain'),\n        ),\n    ) );\n    // conditional field\n    $cmb_demo-\u003eadd_field(array(\n        'name'          =\u003e __( 'Will show on value two selected', 'your-text-domain' ),\n        'desc'          =\u003e __('some description', 'your-text-domain'),\n        'id'            =\u003e 'test_select_depend',\n        'type'          =\u003e 'select',\n        'options'       =\u003e array(\n            'four'   =\u003e __('Four', 'your-text-domain'),\n            'five'   =\u003e __('Five', 'your-text-domain'),\n            'six'    =\u003e __('Six', 'your-text-domain'),\n        ),\n        'attributes'    =\u003e array(\n            'data-conditional-id'     =\u003e 'test_select_id',\n            'data-conditional-value'  =\u003e 'two',\n            // 'data-conditional-invert' =\u003e true\n        ),\n    ) );\n```\n#### You can add more than 1 value to the `data-conditional-value` using ```php wp_json_encode( array( 'value 1', 'value 2' ) ) ``` like so:\n\n```php\n        'attributes'    =\u003e array(\n            'data-conditional-id'     =\u003e 'test_select_id',\n            'data-conditional-value'  =\u003e wp_json_encode( array( 'two', 'three' ) ),\n        ),\n```\n\n\n#### If you like to use this plugin as a stand-alone plugin check my [conditionalScript](https://awran5.github.io/conditional-script/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawran5%2Fcmb2-conditional-logic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawran5%2Fcmb2-conditional-logic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawran5%2Fcmb2-conditional-logic/lists"}