PHPackages                             jt782/require-read-terms-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jt782/require-read-terms-php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

jt782/require-read-terms-php
============================

Display modal for "terms and conditions", and require user read (scroll to bottom) and agree to those terms before submitting form.

1.5.1(4y ago)025[2 issues](https://github.com/jt782/require-read-terms-php/issues)[2 PRs](https://github.com/jt782/require-read-terms-php/pulls)MITPHPPHP ^7.4|^8.0

Since Apr 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jt782/require-read-terms-php)[ Packagist](https://packagist.org/packages/jt782/require-read-terms-php)[ Docs](https://github.com/jt782/require-read-terms-php)[ GitHub Sponsors](https://github.com/jt782)[ RSS](/packages/jt782-require-read-terms-php/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

Require Read/Agree to Terms on Form
===================================

[](#require-readagree-to-terms-on-form)

[![Latest Version on Packagist](https://camo.githubusercontent.com/53a9d95e5be4a0fbb1d0e56e0237b6cec1b6ee6b85d801567552ffceeaa79c5a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a743738322f726571756972652d726561642d7465726d732d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jt782/require-read-terms-php)[![Tests](https://github.com/jt782/require-read-terms-php/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/jt782/require-read-terms-php/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/53a77c274d1a5c6ad1a4dfc4248de917b351c541795a691ff074f057be94a980/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a743738322f726571756972652d726561642d7465726d732d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jt782/require-read-terms-php)

Display modal for "terms and conditions", and require user read (scroll to bottom) and agree to those terms before submitting form.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require jt782/require-read-terms-php
```

Usage
-----

[](#usage)

1. Initialize class with form target (e.g. ".class" or "#id") and terms content:

```
use Seven82Media\RequireReadTerms\FormTerms;

$terms = new FormTerms(
    '#target-form-id',
    'terms go here'
);
```

2. You can modify the following values with these methods:

- Agree Button Text: `$terms->agreeButtonText("Yes, I agree!")`
- Agree Button Color: `$terms->agreeButtonColor("green")`
- Cancel Button Text: `$terms->cancelButtonText("NO, this is dumb!")`
- Cancel Button Color: `$terms->cancelButtonColor("red")`
- Width: `$terms->width("64em")`

3. Within the form, load content and display button:

```
$terms->loadModalDisplayButton()
```

4. If you want more control of the placement of the button vs the script, you can load them separately:

- For button display:

```
$terms->displayButton()
```

- For script output:

```
$terms->loadScript()
```

5. If you have a checkbox for agree to terms, you can hide it visually and have the package check it once the user has agreed to terms:

```
$terms->checkboxFieldTarget("#agree-to-terms");
?>

```

Example
-------

[](#example)

```
