Skip to content

Celerik\Ui\Components\Form ​

Field ​

final class Celerik\Ui\Components\Form\Field

A Bootstrap form control with validation rules.

Rules are emitted as native HTML5 attributes (required, minlength, pattern...), which Parsley.js reads on the client and browsers understand without JavaScript.

Methods ​

input ​

php
static input(string $type, string $name, ?string $label = null): self

text ​

php
static text(string $name, ?string $label = null): self

email ​

php
static email(string $name, ?string $label = null): self

password ​

php
static password(string $name, ?string $label = null): self

number ​

php
static number(string $name, ?string $label = null): self

tel ​

php
static tel(string $name, ?string $label = null): self

date ​

php
static date(string $name, ?string $label = null): self

hidden ​

php
static hidden(string $name, string|int|float $value): self

textarea ​

php
static textarea(string $name, ?string $label = null): self

select ​

php
static select(string $name, array $choices, ?string $label = null): self

checkbox ​

php
static checkbox(string $name, ?string $label = null): self

file ​

php
static file(string $name, ?string $label = null): self

File upload. Without upload() it is a plain file input (the form switches to multipart); with upload() FilePond sends each file to that endpoint first.

editor ​

php
static editor(string $name, ?string $label = null): self

Rich text editor (Quill). Submits HTML: always sanitize it on the server (see EditorHtml::sanitize()).

rules ​

php
rules(UploadRules $rules): self

Accepted files for a file field (defaults to UploadRules::images()). Use the same rules in the UploadHandler.

upload ​

php
upload(string $url): self

Uploads each file asynchronously to this endpoint (FilePond server protocol: POST returns the id as text/plain, DELETE with the id as body reverts it). The form then submits the ids; claim them with UploadHandler::claim().

toolbar ​

php
toolbar(array|string $toolbar): self

Editor toolbar: "basic", "standard" (default), "full", or a Quill toolbar array.

required ​

php
required(bool $required = true): self

minLength ​

php
minLength(int $length): self

maxLength ​

php
maxLength(int $length): self

min ​

php
min(string|int|float $min): self

max ​

php
max(string|int|float $max): self

pattern ​

php
pattern(string $pattern): self

HTML5 pattern (anchored implicitly, no delimiters), e.g. [A-Z]{2}[0-9]{4}.

equalTo ​

php
equalTo(string $fieldName): self

Requires the same value as another field of the form (password confirmation).

mask ​

php
mask(string $mask): self

Inputmask.js mask, e.g. 99/99/9999 or (999) 999-9999.

message ​

php
message(string $message): self

Custom client-side error message for every rule of this field.

placeholder ​

php
placeholder(string $placeholder): self

help ​

php
help(string $help): self

value ​

php
value(mixed $value): self

attribute ​

php
attribute(string $name, string|int|float|bool|null $value = true): self

getName ​

php
getName(): string

getType ​

php
getType(): string

render ​

php
render(string $formId, ?string $error = null, mixed $value = null, bool $floating = false): string
  • $error: Server-side error message to display.
  • $value: Submitted value, takes precedence over the field default.
  • $floating: Bootstrap floating label (text-like inputs, selects and textareas only).

fieldId ​

php
static fieldId(string $formId, string $name): string

isFile ​

php
isFile(): bool

Released under the MIT License.