PHP code example of hypejunction / hypeprototyper

1. Go to this page and download the library: Download hypejunction/hypeprototyper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hypejunction / hypeprototyper example snippets



$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
));


$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
}


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



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',
			'g_for_options(),
		),
		'height' => array(
			'type' => 'text',
			'value_type' => 'number',
			'multiple' => false,
			'show_access' => false,
			'


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,
			)
		));

$shortname => $value
$value
elgg_echo("label:$type:$subtype:$shortname")
elgg_echo("help:$type:$subtype:$shortname")