PHPackages                             flsouto/htchoice - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. flsouto/htchoice

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flsouto/htchoice
================

Abstract class for creating widgets based on choice

1.0.0(9y ago)11123PHP

Since Feb 21Pushed 9y agoCompare

[ Source](https://github.com/flsouto/htchoice)[ Packagist](https://packagist.org/packages/flsouto/htchoice)[ RSS](/packages/flsouto-htchoice/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (2)Used By (3)

HtChoice
========

[](#htchoice)

This library can be extended to easily implement widgets that are based on choice. It is not tied to any specific html element and does not define if the user is supposed to choose only one option or multiple options. This is up to your implementation.

**Notice**: a lot of functionality is already inherited from base abstract classes. So I highly recommend reading these other materials before you start developing with this library:

- HtField
- HtWidget

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

[](#installation)

Use composer:

```
composer require flsouto/htchoice

```

Usage
-----

[](#usage)

For demonstrating how one would extend this abstract class to implement his own choice type of widget, I have prepared a `SimpleChoice` class which provides a text-based list of options and an input field where the user is supposed to type in the value of the desired option. Of course in the real world this would be useless since better control elements such as select, radio buttons and checkboxes already exist for that. However this simplified version will be good for showing how custom choice elements can be implemented if you don't like sticking to the standard ones. So here is the implementation of our `SimpleChoice` class:

```
