PHPackages                             hypejunction/hypeprototyper - 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. hypejunction/hypeprototyper

ActiveElgg-plugin[Utility &amp; Helpers](/categories/utility)

hypejunction/hypeprototyper
===========================

Entity prototyping

7.0.8(5d ago)02141[2 issues](https://github.com/hypeJunction/hypePrototyper/issues)2GPL-2.0-or-laterPHPPHP &gt;=8.3CI failing

Since Aug 11Pushed 2w ago2 watchersCompare

[ Source](https://github.com/hypeJunction/hypePrototyper)[ Packagist](https://packagist.org/packages/hypejunction/hypeprototyper)[ Docs](https://github.com/hypeJunction/hypePrototyper)[ RSS](/packages/hypejunction-hypeprototyper/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (6)Versions (35)Used By (2)

hypePrototyper
==============

[](#hypeprototyper)

[![Elgg 7.x](https://camo.githubusercontent.com/959475d1d91761b2e3ed85398ae1ebe9536a48c724e92bef53e7e2027c3d3627/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456c67672d372e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/959475d1d91761b2e3ed85398ae1ebe9536a48c724e92bef53e7e2027c3d3627/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456c67672d372e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)

A set of developer and administrator tools for prototyping and handling entity forms. This plugin attempts to create an easy way to build forms, validate user input, and display entity profiles.

Developer Notes
---------------

[](#developer-notes)

### Prototypes

[](#prototypes)

Prototypes have 3 different facades:

- *Form* displays a set of inputs that are used to modify entity information
- *Action* validates and handles user input
- *Profile* outputs entity information

Prototypes consist of fields and are meant to be tied to registered Elgg actions. Prototype fields can be populated using `"prototype",$action` plugin hook.

The idea here is that entities of the same type and subtype can be modified by multiple actions. For example, a user entity can be created and modified by `register` and `profile/edit`actions.

Each prototype is tied to an instance of `ElggObject`, `ElggUser` or `ElggGroup`. If the entity does not exist yet, the prototype creates a new instance (but only saves it when the form has been submitted and validated).

### Form

[](#form)

```
$user = elgg_get_logged_in_user_entity();
echo hypePrototyper()->form->with($user, 'profile/edit')->view();
```

```
$form = hypePrototyper()->form->with(array('type' => 'user'), 'register')->viewBody();

echo elgg_view('input/form', array(
	'action' => 'register',
	'body' => $body,
	'enctype' => 'multipart/form-data', // if we have file inputs
));
```

### Action

[](#action)

```
$guid = get_input('guid');
$container_guid = get_input('container_guid');

if (!$guid) {
	$entity = array(
		'type' => 'object',
		'subtype' => 'blog',
		'container_guid' => $container_guid,
	);
} else {
	$entity = get_entity($guid);
}

if (!$entity) {
	// something is wrong
    forward();
}

hypePrototyper()->action->with($entity, 'blog/edit')->handle();
```

```
$entity = array(
	'type' => 'object',
	'subtype' => 'file',
	'access_id' => ACCESS_LOGGED_IN,
);

// In case we want to do more stuff with the new entity
try {
	$controller = hypePrototyper()->action->with($entity, 'file/upload');
	if ($controller->validate()) {
		$entity = $controller->update();
	}
	if ($entity) {
		// do more stuff
	}
} catch (Exception $ex) {
	// do something with the error
}
```

The above will validate the form and add all values to the entity based. If the form validation fails, the user will be forwarded back to the form (forms are made sticky) and failing validation rules will be explained.

### Profile

[](#profile)

```
echo hypePrototyper()->profile->with($group, 'groups/edit')
	->filter(function($field) {
		return in_array($field->getShortname(), array('title', 'description', 'tags'));
	})
	->view($vars);
```

### Fields

[](#fields)

```
elgg_register_plugin_hook_handler('prototype', 'profile/edit', 'prepare_profile_edit_form');

function prepare_profile_edit_form($hook, $type, $return, $params) {

	if (!is_array($return)) {
		$return = array();
	}

	$entity = elgg_extract('entity', $params);

	$fields = array(
		'name' => array(
			'type' => 'text',
			'validation_rules' => array(
				'max_length' => 50
			)
		),
		'briefdescription' => 'longtext',
		'interests' => array(
			'type' => 'tags',
			'required' => true,
			'show_access' => ACCESS_PRIVATE,
		),
		'favorite_foods' => array(
			'type' => 'text',
			'multiple' => true,
			'show_access' => true,
		),
		'eye_color' => array(
			'type' => 'dropdown',
			'label' => elgg_echo('eye_color'),
			'options_values' => array(
				'blue' => elgg_echo('blue'),
				'brown' => elgg_echo('brown'),
			),
		),
		'looking_for' => array(
			'type' => 'checkboxes',
			'label' => false,
			'help' => false,
			'options' => profile_get_looking_for_options(),
		),
		'height' => array(
			'type' => 'text',
			'value_type' => 'number',
			'multiple' => false,
			'show_access' => false,
			'required' => true,
			'validation_rules' => array(
				'min' => 25,
				'max' => 50,
				'minlength' => 2,
				'maxlength' => 4,
			),
		),
		'empathy' => array(
			'type' => 'stars',
			'data_type' => 'annotation',
			'min' => 0,
			'max' => 10,
		),
		'spouse' => array(
			'type' => 'autocomplete',
			'data_type' => 'relationship',
			'value_type' => 'entity',
			'inverse_relationship' => false,
			'bilateral' => true,
			'match_on' => 'friends',
		),
		'icon' => array(
			'data_type' => 'icon',
		),
	);

	return array_merge($return, $fields);
}
```

Fields are defined as `$shortname => $value` pairs, where the `$shortname` is a name of an attribute, metadata, annotation etc. and `$value` is a string that describes the input type (e.g. text, dropdown etc) or an array with the following properties:

- `type` - type of an input, used as elgg\_view("input/$type") (default `text`)
- `data_type` - a model used to store and retrieve values (default `metadata`) > `attribute` - an entity attribute, e.g. guid `metadata` - an entity metadata `annotation` - an entity annotation `relationship` - an entity relationship `icon` - an entity icon `category` - entity categories (hypeCategories)
- `class_name` - PHP class used to instantiate a Field with a custom data type
- `value_type` - type of value if different from `type`, e.g when a text input expects an integer The value type is automatically added to 'type' validation rules, thus setting 'value\_type' =&gt; 'integer' is also equivalent to 'validation\_rules' =&gt; \['type' =&gt; 'integer'\]
- `input_view` - view used to dipslay an input, if different from "input/$type"
- `output_view` - view used to dipslay an output, if different from "output/$type"
- `required` - whether or not a user input is requried (default `false`)
- `admin_only` - whether or not the field is only visible to admins (default `false`)
- `hide_on_profile` - whether or not the field should be hidden on automatically generated profile (default `false`)
- `priority` - order of the field (default `500`)
- `show_access` - whether or not to display an access input (default `false`) This allows users to specify an access level for the metadata, annotation or attachment created
- `label` - what label to display with the input field (default `true`) > `true` - set to `elgg_echo("label:$type:$subtype:$shortname")`; `false` - do not display a label any other custom string
- `help` - what help text to display with the input field (default `true`) > `true` - set to `elgg_echo("help:$type:$subtype:$shortname")`; `false` - do not display help text any other custom string
- `multiple` - whether or not a user can clone the field and add multiple values (default `false`)
- `validation_rules` - an array of rule =&gt; expecation pairs You can define custom validation rules and use `'validate:$rule','prototyper'` to validate the values See hypePrototyperValidators for a full list of available validators
- `options` and `options_values` - array of options to pass to the input
- `flags` - comma-separated list of flags that can be used for input/output filtering
- all other options will be passed to the input view, so you can add `class` for example

The following options are available for `relationship` data type:

- `inverse_relationship` - store as inverse relationship
- `bilateral` - make it a bilateral relationship (two relationships will be added)

### Custom Fields

[](#custom-fields)

To define a new field type, register it as so:

```
hypePrototyper()->config->registerType('icon', \hypeJunction\Prototyper\Elements\IconField::CLASSNAME, array(
			'accept' => 'image/*',
			'value_type' => 'image',
			'multiple' => false,
			'show_access' => false,
			'input_view' => 'input/file',
			'output_view' => false,
			'ui_sections' => array(
				'access' => false,
				'multiple' => false,
			)
		));
```

The above registers a new input type 'icon' with a handler class IconField that extends abstract Field. The third parameter contains default key - value pairs (which can later be overridden in a hook). 'ui\_sections' parameter specifies which sections should be disabled in the admin interface provided by hypePrototyperUI.

Compatibility
-------------

[](#compatibility)

Plugin versionElgg version7.0.07.x6.0.06.x5.0.05.x4.0.04.x3.0.03.x

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance97

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~153 days

Recently: every ~3 days

Total

27

Last Release

5d ago

Major Versions

5.x-dev → 6.0.02026-05-12

3.0.0 → 4.0.02026-05-13

4.0.0 → 5.0.02026-05-13

5.0.0 → 7.0.02026-05-19

6.0.1 → 7.0.12026-06-05

PHP version history (4 changes)6.0.0PHP &gt;=8.2

3.0.0PHP &gt;=7.2

4.0.0PHP &gt;=7.4

7.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/5071b1cd852e094b3f564962a625e04c227adc73af30c5b46b243ab8f20154a7?d=identicon)[hypeJunction](/maintainers/hypeJunction)

---

Top Contributors

[![hypeJunction](https://avatars.githubusercontent.com/u/1202761?v=4)](https://github.com/hypeJunction "hypeJunction (117 commits)")

---

Tags

elggelgg-pluginphppluginelggFormsprototypes

### Embed Badge

![Health badge](/badges/hypejunction-hypeprototyper/health.svg)

```
[![Health](https://phpackages.com/badges/hypejunction-hypeprototyper/health.svg)](https://phpackages.com/packages/hypejunction-hypeprototyper)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
