Files
2025-12-19 16:27:35 -08:00

82 lines
2.1 KiB
PHP

<?php
/**
* @brief T/R/B/L input class for Form Builder
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 07 Feb 2020
*/
namespace IPS\Helpers\Form;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Request;
use IPS\Theme;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* T/R/B/L input class for Form Builder
*/
class Trbl extends FormAbstract
{
/**
* @brief Default Options
* @code
$defaultOptions = array(
);
* @endcode
*/
protected array $defaultOptions = array(
);
/**
* Constructor
*
* @param string $name Name
* @param mixed $defaultValue Default value
* @param bool|NULL $required Required? (NULL for not required, but appears to be so)
* @param array $options Type-specific options
* @param callable|null $customValidationCode Custom validation code
* @param string|null $prefix HTML to show before input field
* @param string|null $suffix HTML to show after input field
* @param string|null $id The ID to add to the row
*/
public function __construct( string $name, mixed $defaultValue=NULL, ?bool $required=FALSE, array $options=array(), callable $customValidationCode=NULL, string $prefix=NULL, string $suffix=NULL, string $id=NULL )
{
parent::__construct( $name, $defaultValue, $required, $options, $customValidationCode, $prefix, $suffix, $id );
if ( !$this->value )
{
$this->value = array( 0, 0, 0, 0 );
}
}
/**
* Get HTML
*
* @return string
*/
public function html(): string
{
return Theme::i()->getTemplate( 'forms', 'core', 'global' )->trbl( $this->name, $this->value[0], $this->value[1], $this->value[2], $this->value[3] );
}
/**
* Get Value
*
* @return mixed
*/
public function getValue(): mixed
{
$name = $this->name;
return Request::i()->$name;
}
}