Copied!

Implements autocomplete for a Select

Use instead of a Select if you have a long list

CloneableInstantiable
Constants
public PHPFUI\Base::DEBUG_SOURCE = 1
Methods
public PHPFUI\HTML5Element::__clone()
public __construct(PHPFUI\Page $page, string $name, string $label = '', bool $freeformInput = false)
 

Construct a SelectAutoComplete. Add options as you would a regular Select

  • param \PHPFUI\Page $page requires JavaScript
  • param string $name of the field
  • param string $label optional
  • param bool $freeformInput if true allow anything to be entered, but will suggest options entered, but will suggest options
public PHPFUI\Base::__toString() : string
public PHPFUI\Base::add(?mixed $item) : static
 

Base add function. Adds to the end of the current objects

  • param mixed $item should be convertable to string
public PHPFUI\Base::addAsFirst(?mixed $item) : static
 

Base addAsFirst function. Adds to the front of the current object

  • param mixed $item should be convertable to string
public PHPFUI\HTML5Element::addAttribute(string $attribute, string $value = '') : static
 

Add an attribute the the object

  • param string $value of the attribute, blank for just a plain attribute
public addAutoCompleteOption(string $option, ?mixed $value) : static
 

Add an option for jQuery-Autocomplete

public PHPFUI\HTML5Element::addClass(string $class) : static
 

Add a class to an object

  • param string $class name(s) to add
public PHPFUI\Input\Input::addErrorMessage(string $error) : static
 

Set a specific error

  • param string $error to display on form validation
public PHPFUI\Input\Select::addLabelClass(string $class) : static
public PHPFUI\Input\Select::addOptGroup(PHPFUI\Input\OptGroup $group) : static
 

Add an OptGroup

public PHPFUI\Input\Select::addOption(string $label, ?string $value = NULL, bool $selected = false, bool $disabled = false) : static
 

Add an option

  • param string $label required
  • param string $value optional
  • param bool $selected default false, pass true to preselect this option this option
  • param bool $disabled default false
public PHPFUI\HTML5Element::addPHPClassName() : static
 

Adds the base PHP class name as a class to this object

public PHPFUI\Input\Select::count() : int
 

Return the number of options added

public PHPFUI\HTML5Element::deleteAttribute(string $attribute) : static
 

Deletes the passed attribute

public PHPFUI\HTML5Element::deleteAttributes() : static
 

Deletes all attributes

public PHPFUI\HTML5Element::deleteClass(string $classToDelete) : static
 

Delete a class from the object

public PHPFUI\HTML5Element::disabled() : static
 

Disabled the element

public PHPFUI\Base::done(bool $done = true) : static
 

Form is done rendering

public PHPFUI\HTML5Element::getAttribute(string $attribute) : ?string
 

Get an attribute

  • return ?string does not exist if null
public PHPFUI\HTML5Element::getAttributes() : string
 

Returns the attribute strings. Attributes with values are returned as name/value pairs, attributes without values are returned as just the attribute name.

public PHPFUI\HTML5Element::getClass() : string
 

Returns the class attribute ready for insertion into an element.

public PHPFUI\HTML5Element::getClasses() : array
 

Returns all classes for the object

  • return string[]
public static PHPFUI\Base::getDebug(int $flags = 0) : int
 

Gets the current debug setting

public PHPFUI\Input::getDisabled() : bool
 

Return true if disabled

public PHPFUI\HTML5Element::getElement() : string
 

Return the type of the element

public PHPFUI\Input\Input::getError() : ?PHPFUI\HTML5Element
 

Get the error message for placement else where. If this is called, the error mesage will not be incorporated automatically, but must be placed by the caller

public getHiddenField() : PHPFUI\Input\Hidden
 

Returns the hidden field which is where the autocompleted value will be stored. The hidden field name is the same name as the AutoComplete field was constructed with. This should generally be used to save the value the user has selected when 'save' is passed to the callback.

public PHPFUI\Input\Input::getHint() : ?PHPFUI\HTML5Element
public PHPFUI\HTML5Element::getId() : string
 

Return the id of the object. Elements will not have an id unless this method is called. The id is returned as a string starting with id followed by a unique number to the page. Id numbers are deterministic and start start with 1. Once assigned an id, an element will always have the same id. It will get a new id if cloned.

public PHPFUI\HTML5Element::getIdAttribute() : string
 

Return the id attribute of the object as a name/value pair. If no id has been requested, and empty string is returned.

public PHPFUI\Input\Input::getLabel() : string
 

Return the label for the input field

public PHPFUI\Input::getName() : string
 

Returns the name of the input field

public getPage() : PHPFUI\Interfaces\Page
public PHPFUI\Input::getPlaceholder() : string
 

Returns the current placeholder

public PHPFUI\Input\Input::getRequired() : bool
public PHPFUI\Base::getResponse() : string
 

Get the current response

public PHPFUI\HTML5Element::getToolTip(string $label) : PHPFUI\ToolTip|string
 

Get the tool tip as a string

  • return \ToolTip|string return type depends on if the tip was set as a string or ToolTip object.
public PHPFUI\Input::getType() : string
 

Returns the type of the input field

public PHPFUI\Input::getValue() : string
 

Return the initial value of the input field

public PHPFUI\HTML5Element::hasClass(string $class) : bool
 

Return true if the class is present on the object

public PHPFUI\HTML5Element::hasId() : bool
 

Does this object have an id set already?

public PHPFUI\HTML5Element::hasToolTip() : bool
 
  • return bool if there is a tool tip associated with this element
public inReveal(bool $isInRevealModal = true) : self
 

Called recursively by Reveal to force fixed postion autocomplete hints.

public PHPFUI\Base::isDone() : bool
 

Returns true if the page needs no more processing

public PHPFUI\HTML5Element::newId() : static
 

Assign a new id to this element.

public PHPFUI\Base::prepend(?mixed $item) : static
 

Add an object in front of existing object

public PHPFUI\Input\Select::removeAll() : static
 

Remove all options.

public removeAutoCompleteOption(string $option) : static
 

Remove an option for jQuery-Autocomplete

public PHPFUI\Input\Select::removeOption(string $value) : bool
 

Remove an option. Returns true on success.

  • param string $value of selection to be removed
  • return bool returns true if option was removed.
public PHPFUI\Input\Select::select(string $selection) : static
 

Select an option based on the value passed

  • param string $selection to be selected
public setArray(string $name) : static
 

If you have mutiple SelectAutoComplete fields of the same type on a page, you can set the array name to avoid multiple copies of the JavaScript array used for autocomplete.

Set the second and subsequent SelectAutoComplete fields to an array name of the first SelectAutoComplete name.

public PHPFUI\HTML5Element::setAttribute(string $attribute, string $value = '') : static
 

Set the attribute overwriting the prior value

  • param string $value of the attribute, blank for just a plain attribute
public PHPFUI\HTML5Element::setConfirm( $text) : static
 

A simple way to set a confirm on click

  • param string $text confirm text
public PHPFUI\Input\Input::setDataMask(PHPFUI\Interfaces\Page $page, string $mask) : static
public static PHPFUI\Base::setDebug(int $level = 0) : void
 

Set the debug level, 1 or higher is on

public PHPFUI\Input::setDisabled(bool $disabled = true) : static
 

Set disabled

public PHPFUI\HTML5Element::setElement( $element) : static
 

You can set the element type if you need to morph it for some reason

  • param string $element
public PHPFUI\Input\Input::setErrorMessages(array $errors) : static
 

Set all error messages

  • param string[] $errors to display on form validation
public PHPFUI\Input\Input::setHint(string $hint) : static
 

Set a hint

  • param string $hint to display with input
public PHPFUI\HTML5Element::setId( $id) : static
 

Set the base id of the object

  • param string $id to set. Will be returned as set. It is up to the caller to prevent duplicate ids.
public PHPFUI\Input\Input::setLabel(string $label) : static
 

Set a label if not specified in constructor

public PHPFUI\Input::setName(string $name) : static
public PHPFUI\Input::setPlaceholder(string $placeholder) : static
public PHPFUI\Base::setRawResponse(string $response, bool $asJSON = true) : static
 

Sets the page response directly and exits the program

  • return never|static
public PHPFUI\Input\Input::setRequired(bool $required = true) : static
 

Set required

  • param bool $required default true
public PHPFUI\Base::setResponse(string $response, string $color = 'lime') : static
 

Set a response in the standard format ('reponse' and 'color' array) exit will be called after returning the encoded response

  • param string $response to return
  • param string $color used for the save button
  • return never|static
public setToolTip(PHPFUI\ToolTip|string $tip) : static
 

Set the tool tip. Can either be a ToolTip or a string. If it is a string, it will be converted to a ToolTip

public PHPFUI\Input\Input::setValidator(PHPFUI\Validator $validator, string $errorMessage = '', ?string $data = NULL) : static
 

Set the validator for this input field. You must also add it to the page with addAbideValidator()

public PHPFUI\Input::setValue(string $value) : static
 

Set the initial value of the input field

public PHPFUI\HTML5Element::toggleAnimate(PHPFUI\HTML5Element $element, string $animation) : static
 

Will toggle the provided element on click with the provided animation.

public PHPFUI\HTML5Element::toggleClass(PHPFUI\HTML5Element $element, string $class) : static
 

Will toggle the class on the provided element on click.

public PHPFUI\Input\Input::toggleFocus(PHPFUI\HTML5Element $element) : static
 

Toggle the passed in element when this field gets focus.

public PHPFUI\HTML5Element::transferAttributes(PHPFUI\HTML5Element $from) : static
 

Moves attributes into this object from the passed object

public PHPFUI\HTML5Element::transferClasses(PHPFUI\HTML5Element $from) : static
 

Moves classes into this object from the passed object

public PHPFUI\Base::walk(string $method, ?mixed $argument = NULL) : static
 

Recursively walks all objects and calls the passed method on each object where it exists

  • param string $method to call on the object in the collection
  • param mixed $argument to pass to the method
Properties
protected string $acFieldId
protected PHPFUI\Input\Text $acInput
protected string $arrayName = ''
protected array $autoCompleteOptions = ['minChars' => '1', 'type' => ''POST'', 'autoSelectFirst' => 'true', 'lookup' => 'arrayName', 'onSelect' => 'function(suggestion){ac.attr("placeholder",suggestion.value);ac.val("");fld.val(suggestion.data);fld.change()}']
 
  • var array<string,string|bool>
protected bool PHPFUI\Input::$disabled = false
protected ?PHPFUI\HTML5Element PHPFUI\Input\Input::$error = NULL
protected array PHPFUI\Input\Input::$errorMessages = []
 
  • var string[]
protected bool $freeformInput
protected PHPFUI\Input\Hidden $hidden
protected ?PHPFUI\HTML5Element PHPFUI\Input\Input::$hint = NULL
protected string PHPFUI\Input\Input::$hintText = ''
protected ?string PHPFUI\Input\Input::$label
protected array PHPFUI\Input\Select::$labelClass = []
 
  • var string[]
protected string PHPFUI\Input::$name
protected array PHPFUI\Input\Select::$options = []
 
  • var (\PHPFUI\Input\OptGroup|array<string,string>)[]
protected PHPFUI\Page $page
protected string PHPFUI\Input::$placeholder = ''
protected string $realName
protected bool PHPFUI\Input\Input::$required = false
protected PHPFUI\ToolTip|string $toolTip = ''
protected string PHPFUI\Input::$type = ''
protected ?string PHPFUI\Input::$value
Methods
protected getBody() : string
protected getEnd() : string
protected PHPFUI\Base::getItems() : array
 
  • return array
protected getStart() : string
protected PHPFUI\Input\Input::setAutoCompleteRequired(PHPFUI\Page $page, PHPFUI\Input\Input $text) : void
protected PHPFUI\HTML5Element::upCastCopy(PHPFUI\HTML5Element $to, PHPFUI\HTML5Element $from) : object
 

Clones the first object and fills it with properties from the second object

Methods
private escapeData(?string $data) : string
Methods
public static PHPFUI\Base::getDebug(int $flags = 0) : int
 

Gets the current debug setting

public static PHPFUI\Base::setDebug(int $level = 0) : void
 

Set the debug level, 1 or higher is on

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration