fields

object

%field

/phlo/resources/fields/field.phlo
type abstract class
version 1.0
creator q-ai.nl
summary Base ORM field
package fields
frontend false
backend true
tags field orm
function

function field ($type, ...$args)

line 10
创建一个具有指定类型和附加参数的字段,使用phlo函数为字段生成唯一标识符。
phlo("field_$type", ...$args, type: $type)
static

field :: __handle

line 12
此属性用于访问Phlo中字段对象的内部句柄。
null
prop

%field -> title

line 14
此表达式获取当前对象的'name'属性,并将首字母大写。
ucfirst($this->name)
method

%field -> input ($record)

line 16
根据指定的类型、名称和提供的记录中的值生成输入字段,并可选地添加maxlength和placeholder属性。
input(type: $this->type, name: $this->name, value: $record->{$this->name} ?? $this->default, maxlength: $this->length, placeholder: $this->placeholder, class: 'field')
method

%field -> label ($record)

line 17
使用字段的名称从指定记录中检索字段的标签。
$record->{$this->name};
prop

%field -> objColumns

line 19
此属性在字段的上下文中检索指定obj的列。
[]
method

%field -> objValidate ($value)

line 21
根据指定的规则(如必需、长度、模式和枚举约束)验证给定的值,如果验证失败则返回错误消息。
if (($value === null || $value === void) && $this->required) return $this->title.' is required'
if ($value === null || $value === void) return null
if ($this->length && is_string($value) && mb_strlen($value) > $this->length) return $this->title.' is too long (max '.$this->length.')'
if ($this->pattern && is_string($value) && !preg_match('/'.str_replace('/', '\\/', $this->pattern).'/', $value)) return $this->title.' has invalid format'
if ($this->enum && !in_array($value, (array)$this->enum, true)) return $this->title.' must be one of: '.implode(', ', (array)$this->enum)
return null
object

%field_bool

/phlo/resources/fields/bool.phlo
extends field
class field_bool
version 1.0
creator q-ai.nl
summary Boolean field
package fields
frontend true
backend true
tags field boolean input
prop

%field_bool -> true

line 11
表示一个布尔字段,其值为真,显示为勾号符号 '✅'。
'✅'
prop

%field_bool -> false

line 12
表示默认值为 false 的布尔字段,显示为 '❌'。
'❌'
method

%field_bool -> label ($record)

line 14
返回给定记录中布尔字段对应的标签,根据字段的值返回真标签或假标签。
$record->{$this->name} ? $this->true : $this->false
method

%field_bool -> input ($record)

line 15
生成一个基于提供的记录值的布尔值复选框输入字段,并带有标签。
tag('label', inner: input(type: 'checkbox', name: $this->name, value: 1, checked: $record->{$this->name} ? false : null).tag('span', class: 'slider', inner: void))
method

%field_bool -> parse ($record)

line 16
从有效负载中解析布尔值,并将其分配给记录中的指定字段。
$record->{$this->name} = (bool)%payload->{$this->name};
method

%field_bool -> nullable

line 17
此函数将布尔字段转换为可空类型,使其能够表示真、假或空值。
false
prop

%field_bool -> objColumns

line 19
访问与对象上下文中的布尔字段相关联的列。
[$this->name]
object

%field_child

/phlo/resources/fields/child.phlo
extends field
class field_child
version 1.0
creator q-ai.nl
summary Child relation field
package fields
frontend true
backend true
tags field relation child
prop

%field_child -> list

line 11
访问列表中field_child对象的'count'属性。
'count'
prop

%field_child -> change

line 12
field_child->$change 属性指示子字段是否发生了任何更改,布尔值 false 表示没有发生更改。
false
prop

%field_child -> create

line 13
该表达式的值为false,表示field_child属性不支持create操作。
false
prop

%field_child -> record

line 14
访问列表中当前字段的子记录。
'list'
method

%field_child -> count ($record)

line 16
计算与给定记录关联的子记录数量并返回该数量。
tag('a', href: slash.($record::$uriRecord ?? $record::class).slash.$record->id.slash.$this->name, class: 'async', inner: $record->getCount($this->name).space.$this->title)
method

%field_child -> last ($record)

line 17
从给定记录中检索指定字段的最后一个值。
$record->getLast($this->name)
method

%field_child -> label ($record)

line 18
从给定记录中检索子字段的标签,如果未找到标签,则返回破折号。
implode(loop($record->{$this->name}, fn($child) => $this->link($child))) ?: dash
method

%field_child -> input ($record)

line 19
生成一个与特定记录相关联的输入字段,使用标签方法显示相应的标签。
$this->label($record)
method
line 20
生成一个锚点(`<a>`)元素,链接到由给定的 `$record` 标识的资源,使用其 URI 和 ID,并应用 'async' 类以实现异步加载。
tag('a', href: slash.($record::$uriRecord ?? $record::class).slash.$record->id, class: 'async', inner: $record)
object

%field_date

/phlo/resources/fields/date.phlo
extends field
class field_date
version 1.0
creator q-ai.nl
summary Date field
package fields
frontend false
backend true
tags field date
prop

%field_date -> handle

line 11
该表达式检索与field_date对象关联的句柄,如果存在则返回true。
true
prop

%field_date -> objColumns

line 13
使用名称属性访问指定对象列的日期字段。
[$this->name]
object

%field_datetime

/phlo/resources/fields/datetime.phlo
extends field
class field_datetime
version 1.0
creator q-ai.nl
summary Date-time field
package fields
frontend true
backend true
tags field datetime
prop

%field_datetime -> handle

line 11
field_datetime->$handle 表达式用于访问 Phlo 中 datetime 字段的句柄。
true
prop

%field_datetime -> change

line 12
该项检查字段名称是否不是 'created' 或 'changed',然后才允许对日期时间字段进行更改。
!in_array($this->name, ['created', 'changed'])
prop

%field_datetime -> create

line 13
检查字段名称是否不是 'created' 或 'changed'。
!in_array($this->name, ['created', 'changed'])
method

%field_datetime -> label ($record)

line 15
为记录中的日期时间字段生成标签,如果存在值,则显示图标和可读的时间格式。
($value = $record->{$this->name}) ? tag('i', class: 'icon clock-'.$this->labelIconClass(time() - $value), inner: void).tag('span', data_ts: $record->{$this->name}, inner: time_human($record->{$this->name})) : dash
method

%field_datetime -> labelIconClass ($value)

line 16
根据时间值(以秒为单位)返回颜色类,超过一天为'红色',超过一小时为'黄色',否则为'蓝色'。
$value > 86400 ? 'red' : ($value > 3600 ? 'yellow' : 'blue')
method

%field_datetime -> input ($record)

line 17
为指定记录生成一个类型为'datetime-local'的输入字段,预填充格式化的日期和时间值。
input(type: 'datetime-local', name: $this->name, value: date('Y-m-d\TH:i', $record->{$this->name}), class: 'field')
method

%field_datetime -> parse ($record)

line 18
从记录中解析日期时间字段,如果'created'尚未设置,则将其设置为当前时间,更新'changed'为当前时间,或者如果存在,则将有效负载值转换为时间戳。
if ($this->name === 'created') $record->created ??= time()
elseif ($this->name === 'changed') $record->{$this->name} = time()
elseif ($payload = %payload->{$this->name}) $record->{$this->name} = strtotime($payload)
prop

%field_datetime -> objColumns

line 24
访问与field_datetime对象相关联的列,返回其名称。
[$this->name]
object

%field_email

/phlo/resources/fields/email.phlo
extends field_text
class field_email
version 1.0
creator q-ai.nl
summary Email field
package fields
frontend false
backend true
tags field email
view

%field_email -> label ($record)

line 12
此视图为存储在记录中的电子邮件地址生成一个mailto链接,允许用户点击直接发送电子邮件。
<a href="mailto:{{ $record->{$this->name} }}">{{ $record->{$this->name} }}</a>
object

%field_file

/phlo/resources/fields/file.phlo
extends field
class field_file
version 1.0
creator q-ai.nl
summary File field
package fields
frontend true
backend true
tags field file upload
prop

%field_file -> canDelete

line 11
`field_file->$canDelete` 属性指示文件是否可以被删除。
true
prop

%field_file -> delete

line 12
在删除文件之前提示用户确认。
'Delete file?'
prop

%field_file -> path

line 13
`field_file->$path` 获取与资源上下文中特定文件字段关联的文件路径。
files
prop

%field_file -> uri

line 14
该属性返回存储在'/files/'目录中的文件的URI。
'/files/'
prop

%field_file -> length

line 15
`field_file` 的 `$length` 属性返回文件的大小(以字节为单位)。
100
method

%field_file -> label ($record)

line 17
为给定记录关联的文件生成超链接,使用文件名和安全访问的令牌。如果没有文件,则返回一个破折号。
($filename = $record->{$this->name}) ? tag('a', href: $this->uri.$record->{$this->name.'_token'}.slash.rawurlencode($filename), target: 'file', inner: tag('i', class: 'icon '.pathinfo($filename, PATHINFO_EXTENSION), inner: void).$filename) : dash
method

%field_file -> input ($record)

line 18
生成一个用于文件上传的HTML输入字段,如果可用,则显示当前文件名,并提供删除文件的选项。
$input = void
$file = ($filename = $record->{$this->name}) ? $this->read($record) : null
$input .= lf.tab.tag('div', class: 'file', inner: $file ? tag('i', class: "icon $file->ext", inner: void).$filename : '-select-')
$input .= lf.tab.input(type: 'file', class: 'file-input', name: $this->name, accept: '.pdf')
$file && $this->canDelete && $input .= lf.tab.tag('div', inner: tag('label', inner: input(type: 'checkbox', name: $this->name.'Delete')." $this->delete"))
return $input.lf
method

%field_file -> parse ($record)

line 27
从有效负载中解析文件,处理删除并在有效时写入文件,并使用文件的缩短名称和令牌更新记录。
$file = %payload->{$this->name};
if ($delete = %payload->{$this->name.'Delete'}) unset(%payload->{$this->name.'Delete'})
if ($record->{$this->name} && $delete && $this->canDelete) $record->{$this->name} = $record->{$this->name.'_token'} = null
if (is_a($file, 'file')){
	$token = $file->token
	if (!$this->write($file)) return
	$record->{$this->name} = $file->shortenTo($this->length)
	$record->{$this->name.'_token'} = $token
}
method

%field_file -> read ($record, $path = null)

line 39
读取与记录关联的文件,使用指定路径或默认路径,并返回文件的内容以及其名称和附加信息。
$filename = $record->{$this->name};
$token = $record->{$this->name.'_token'};
return %file(($path ?? $this->path).($info = substr($token, 0, 2).slash.substr($token, 2).dot.pathinfo($filename, PATHINFO_EXTENSION)), name: $filename, info: $info)
method

%field_file -> write ($file)

line 45
将指定的文件写入指定路径,如有必要则移动,并在写入操作失败时触发错误。
file_exists($dest = $this->writePath($file)) || $file->move($dest) || error("Couldn't write: $dest")
method

%field_file -> writePath ($file, $path = null)

line 46
将文件写入指定路径,如果目录不存在则创建,并返回写入文件的完整路径。
$token = $file->token
$path = ($path ?? $this->path).substr($token, 0, 2)
is_dir($path) || mkdir($path) || error("Couldn't create: $path")
return $path.slash.substr($token, 2).dot.$file->ext
prop

%field_file -> objColumns

line 53
此属性检索包含字段名称及其关联令牌的数组,用于指定的对象列。
[$this->name, $this->name.'_token']
view

script

line 55
该脚本通过在点击相关标签时触发文件输入的点击,并在选择文件时用所选文件名更新标签文本,来处理文件输入交互。
on('click', '.input.file .file', (file) => file.nextElementSibling.click())
on('change', '.input.file .file-input', (input) => input.previousElementSibling.innerText = input.files[0].name)
object

%field_image

/phlo/resources/fields/image.phlo
extends field_file
class field_image
version 1.0
creator q-ai.nl
summary Image field
package fields
frontend true
backend true
tags field image upload
prop

%field_image -> delete

line 11
向用户提示确认消息,询问他们是否要删除该图像。
'Delete image?'
prop

%field_image -> uri

line 12
该表达式通过将基本路径 '/images/' 附加到字段的值来检索图像字段的 URI。
'/images/'
prop

%field_image -> path

line 13
`field_image->$path` 访问存储在 `field_image` 资源中的图像路径。
images
prop

%field_image -> thumbPath

line 14
在`field_image`对象中的`thumbPath`字段检索存储在`thumbs`资源中的缩略图路径。
thumbs
prop

%field_image -> thumbSize

line 15
`field_image->$thumbSize` 属性定义了 Phlo 中给定字段的缩略图像大小。
64
prop

%field_image -> thumbUri

line 16
该 prop 通过将 '/thumbs/' 附加到 field_image 值来生成缩略图 URI。
'/thumbs/'
method

%field_image -> label ($record)

line 18
生成一个包含图像的HTML锚标签,链接到基于提供的记录数据的指定URI。如果记录不包含文件名,则返回一个破折号。
($filename = $record->{$this->name}) ? tag('a', href: $this->uri.($url = $record->{$this->name.'_token'}.slash.rawurlencode($filename)), target: 'image', inner: tag('img', src: $this->thumbUri.$url)) : dash
method

%field_image -> input ($record)

line 19
生成一个用于上传图像的HTML输入元素,如果可用,还会显示当前图像的预览,并提供一个可选的复选框用于删除图像。
$input = void
$file = $record->{$this->name} ? $this->read($record, $this->thumbPath) : null
$input .= lf.tab.tag('img', src: $file ? $this->thumbUri.$record->{$this->name.'_token'}.slash.rawurlencode($record->{$this->name}) : '/image.select.jpg', class: 'image')
$input .= lf.tab.input(type: 'file', class: 'image-input',  name: $this->name, accept: 'image/*', data_size: $this->thumbSize)
$file && $this->canDelete && $input .= lf.tab.tag('div', inner: tag('label', inner: input(type: 'checkbox', name: $this->name.'Delete')." $this->delete"))
return $input.lf
method

%field_image -> write ($file)

line 28
将图像文件写入指定路径,并将原始文件移动到另一个位置,同时将图像缩放到定义的缩略图大小。
%img($file->file)->scale($this->thumbSize, $this->thumbSize)->save($this->writePath($file, $this->thumbPath)) && $file->move($this->writePath($file))
prop

%field_image -> objColumns

line 30
此表达式检索与field_image相关的列,具体来说是由对象的名称及其令牌变体定义的列名。
[$this->name, $this->name.'_token']
view

script

line 32
该脚本处理图像元素的点击事件以触发文件输入,并在更新前一个兄弟元素的源之前处理图像更改以调整上传图像的大小。
on('click', '.input.image .image', (img) => img.nextElementSibling.click())
on('change', '.input.image .image-input', (input) => imageResizer(input.files[0], input.dataset.size, input.dataset.size, (image) => input.previousElementSibling.src = image))
object

%field_many

/phlo/resources/fields/many.phlo
extends field
class field_many
version 1.0
creator q-ai.nl
summary Many-to-many relation field
package fields
frontend true
backend true
tags field relation many
prop

%field_many -> list

line 11
field_many->$list 属性用于在 Phlo 应用程序中定义字段的标签列表。
'label'
prop

%field_many -> record

line 12
访问集合中每个记录的 'label' 字段。
'label'
prop

%field_many -> create

line 13
在资源中创建多个字段实例。
false
prop

%field_many -> change

line 14
field_many->$change 属性指示字段值是否发生了变化。
false
method

%field_many -> count ($record)

line 16
返回与给定记录中指定字段名称相关联的记录数量。
$record->getCount($this->name)
method

%field_many -> label ($record)

line 17
从给定记录生成许多对多关系中每个项目的标签,并链接到相关实体。
loop($record->{$this->name}, fn($relation) => $this->link($relation), lf) ?: dash
method
line 18
生成一个锚点(`<a>`)元素,链接到特定记录的URI,使用记录的ID和类作为URL,并应用'async'类以实现异步加载。
tag('a', href: slash.($record::$uriRecord ?? $record::class).slash.$record->id, class: 'async', inner: $record)
method

%field_many -> input ($record)

line 19
为指定记录中的每个项目生成一个输入字段,使用 label 方法设置字段的标签。
$this->label($record)
prop

%field_many -> objColumns

line 21
field_many->$objColumns 属性保存与 Phlo 资源中的多对多关系相关联的列对象数组。
[]
object

%field_multiselect

/phlo/resources/fields/multiselect.phlo
extends field
class field_multiselect
version 1.0
creator q-ai.nl
summary Multi-select via checkboxes; slaat de keuze als CSV op in één verborgen veld (geen save-aanpassing nodig).
package fields
frontend false
backend true
tags field select multi
method

%field_multiselect -> label ($record)

line 11
根据提供的记录返回多选字段的标签,如果值为空则默认为短横线。
($v = (string)($record->{$this->name} ?? '')) !== '' ? $v : dash
method

%field_multiselect -> input ($record)

line 13
$current = array_filter(array_map('trim', explode(',', (string)($record->{$this->name} ?? ''))))
$js = "var f=this.closest('.field');f.querySelector('input.msv').value=[...f.querySelectorAll('input.msc:checked')].map(c=>c.value).join(',')"
$boxes = loop((array)$this->options, fn($o) => tag('label', tag('input', type: 'checkbox', value: (string)$o, class: 'msc', checked: in_array((string)$o, $current) ? true : void, onchange: $js).esc((string)$o), class: 'ms-opt'), void)
return tag('input', type: 'hidden', name: $this->name, value: implode(',', $current), class: 'msv').tag('div', $boxes ?: tag('span', 'geen opties', class: 'muted'), class: 'ms-grid')
prop

%field_multiselect -> objColumns

line 20
这从当前对象上下文中检索由名称属性标识的字段的值。
[$this->name]
object

%field_number

/phlo/resources/fields/number.phlo
extends field
class field_number
version 1.0
creator q-ai.nl
summary Number field
package fields
frontend true
backend true
tags field number
prop

%field_number -> decimals

line 11
`field_number->$decimals` 属性指定 Phlo 中数字字段的小数位数。
prop

%field_number -> length

line 12
这定义了field_number的长度属性,指定允许的最大数字位数。
5
prop

%field_number -> min

line 13
此 prop 定义了视图中数字字段的最小值。
method

%field_number -> label ($record)

line 15
根据指定的小数位格式化给定记录中的数字字段,使用逗号作为千位分隔符,点作为小数点。
number_format($record->{$this->name}, $this->decimals, comma, dot)
method

%field_number -> input ($record)

line 16
生成一个类型为'number'的HTML输入元素,具有指定的属性,包括名称、值、步长和最小值,使用提供的记录中的数据。
input(type: 'number', name: $this->name, value: $record->{$this->name} ?? $this->default, step: $this->decimals ? dot.str_repeat('0', $this->decimals - 1).'1' : null, min: $this->min, class: 'field')
prop

%field_number -> objColumns

line 18
使用当前对象实例的名称访问与该字段相关联的列数据。
[$this->name]
object

%field_parent

/phlo/resources/fields/parent.phlo
extends field
class field_parent
version 1.0
creator q-ai.nl
summary Parent relation field
package fields
frontend false
backend true
tags field relation parent
method

%field_parent -> label ($record)

line 11
返回给定记录的父字段的标签,如果适用则链接到模型,否则返回一个破折号。
is_a($obj = $record->{$this->name}, 'model') ? $this->link($obj) : dash
method

%field_parent -> input ($record)

line 12
生成一个HTML <select> 输入元素,基于提供的 $record 填充选项,如果选项的ID与记录的ID匹配,则将其标记为选中。
select(name: $this->name, inner: loop($this->options, fn($parent) => '<option'.($parent->id === $record->{$this->name}?->id ? ' selected' : void).' value="'.$parent->id.'">'.$parent, void))
method
line 13
生成一个锚点(`<a>`)HTML元素,链接到特定记录的URI,使用记录的ID和可选的内部内容。
tag('a', href: slash.($record::$uriRecord ?? $record::class).slash.$record->id, class: 'async', inner: $content ?? $record)
prop

%field_parent -> options

line 14
访问与当前对象记录上下文中的父字段相关联的选项。
$this->obj::records()
prop

%field_parent -> objColumns

line 16
在当前字段的上下文中访问父对象的列。
[$this->name]
object

%field_password

/phlo/resources/fields/password.phlo
extends field
class field_password
version 1.0
creator q-ai.nl
summary Password field
package fields
frontend false
backend true
tags field password
prop

%field_password -> list

line 11
field_password->$list 表达式用于访问 Phlo 应用程序中的密码字段列表,如果不存在这样的字段,则返回 false。
false
prop

%field_password -> required

line 12
指定密码字段在表单提交时是否为必填项,值为true表示该字段是必需的。
true
prop

%field_password -> minlength

line 13
设置密码字段的最小长度要求。
8
prop

%field_password -> placeholder

line 14
将密码输入字段的占位符文本设置为 'New password'。
'New password'
method

%field_password -> input ($record)

line 16
生成一个密码输入字段,具有指定的属性,如类型、名称、占位符和类。
input(type: $this->type, name: $this->name, placeholder: $this->placeholder, class: 'field')
method

%field_password -> label ($record)

line 17
根据提供的记录生成密码字段的标签。
'••••••••'
method

%field_password -> parse ($record)

line 18
从有效负载中解析密码字段,修剪它,并使用 PASSWORD_BCRYPT 进行哈希,然后将其存储在记录中。
($password = trim(%payload->{$this->name})) && $record->{$this->name} = password_hash($password, PASSWORD_BCRYPT)
prop

%field_password -> objColumns

line 20
使用当前对象的名称作为键,从objColumns数组中访问密码字段。
[$this->name]
object

%field_price

/phlo/resources/fields/price.phlo
class field_price
version 1.0
creator q-ai.nl
summary Price field
package fields
frontend false
backend true
tags field price money
extends field_number
prop

%field_price -> decimals

line 11
此属性定义价格字段的小数位数。
2
object

%field_select

/phlo/resources/fields/select.phlo
extends field
class field_select
version 1.0
creator q-ai.nl
summary Select field
package fields
frontend false
backend true
tags field select
method

%field_select -> input ($record)

line 11
根据提供的 $record 生成一个选择输入字段,如果当前选项与 $record 中的值匹配,则将其标记为选中。
select(name: $this->name, inner: loop($this->options, fn($option) => "<option".($record->{$this->name} === $option ? ' selected' : void).">$option", void))
prop

%field_select -> objColumns

line 13
在字段选择的上下文中访问与当前对象名称相关联的列数据。
[$this->name]
object

%field_text

/phlo/resources/fields/text.phlo
extends field
class field_text
version 1.0
creator q-ai.nl
summary Text field
package fields
frontend false
backend true
tags field text
prop

%field_text -> length

line 11
field_text->$length 属性返回字段中文本的长度,作为一个整数。
100
prop

%field_text -> multiline

line 12
field_text->$multiline 属性根据长度超过 250 个字符的条件来确定文本字段是否允许多行输入。
$this->length > 250
method

%field_text -> label ($record)

line 14
此函数从给定记录中检索文本字段的标签,如果值超过100个字符,则进行截断,并用HTML换行符替换换行符。
($value = $record->{$this->name}) === null ? dash : strtr(strlen($value) > 100 ? substr($value, 0, 80).'...' : $value, [lf => br])
method

%field_text -> input ($record)

line 15
生成一个文本输入字段,根据multiline属性使用多行输入或单行输入。
$this->multiline ? $this->inputMulti($record) : $this->inputField($record)
method

%field_text -> inputField ($record)

line 16
生成一个表单的输入字段,使用指定的类型、名称、值、最大长度、占位符和类属性。
input(type: $this->type, name: $this->name, value: ($value = $record->{$this->name}) ? esc($value) : $this->default, maxlength: $this->length, placeholder: $this->placeholder, class: 'field')
method

%field_text -> inputMulti ($record)

line 17
使用textarea元素生成多行文本输入字段,如果提供的记录中没有值,则用默认值预填充。
textarea(name: $this->name, inner: ($value = $record->{$this->name}) ? esc($value) : $this->default ?? void, placeholder: $this->placeholder, class: 'field')
prop

%field_text -> objColumns

line 19
访问与字段名称关联的对象中的列数据。
[$this->name]
object

%field_token

/phlo/resources/fields/token.phlo
extends field
class field_token
version 1.0
creator q-ai.nl
summary Token field
package fields
frontend false
backend true
tags field token
prop

%field_token -> length

line 11
返回 field_token 的长度,类型为整数。
8
prop

%field_token -> default

line 12
使用token函数生成指定长度的默认令牌。
token($this->length)
prop

%field_token -> create

line 13
在资源的上下文中创建一个新的字段令牌,如果操作失败则返回false。
false
prop

%field_token -> change

line 14
field_token->$change 表达式的值为 false,表示字段令牌没有变化。
false
prop

%field_token -> search

line 15
field_token->$search 表达式的值为 true,表示该字段令牌的搜索功能已启用。
true
method

%field_token -> label ($record)

line 17
此函数从给定记录中检索字段令牌的标签,并将其包装在'div'标签中,转义任何特殊字符。
tag('div', inner: esc($record->{$this->name}))
method

%field_token -> parse ($record)

line 18
从给定记录中解析字段令牌,如果令牌不存在,则分配默认值。
$record->{$this->name} ??= $this->default
prop

%field_token -> objColumns

line 20
访问与当前对象上下文中的字段令牌关联的列数据。
[$this->name]
object

%field_virtual

/phlo/resources/fields/virtual.phlo
extends field
class field_virtual
version 1.0
creator q-ai.nl
summary Virtual field
package fields
frontend false
backend true
tags field virtual
prop

%field_virtual -> create

line 11
此属性指示该字段是否为虚拟字段,并应动态创建。
false
prop

%field_virtual -> change

line 12
field_virtual->$change 属性指示虚拟字段是否已从其先前值更改。
false
prop

%field_virtual -> objColumns

line 14
field_virtual->$objColumns 属性用于访问对象中虚拟字段的列。
[]
object

%field_wysiwyg

/phlo/resources/fields/wysiwyg.phlo
extends field
class field_wysiwyg
version 1.0
creator q-ai.nl
summary WYSIWYG field
package fields
frontend true
backend true
tags field wysiwyg editor
method

%field_wysiwyg -> input ($record)

line 11
生成一个所见即所得的编辑器输入字段,包括一个用于文本格式化的工具栏和一个隐藏输入以存储值。
$value = $record->{$this->name} ?? $this->default ?? void
$toolbar = tag('div', class: 'toolbar', inner: tag('button', type: 'button', data_command: 'bold', inner: '<b>B</b>').tag('button', type: 'button', data_command: 'italic', inner: '<i>I</i>').tag('button', type: 'button', data_command: 'underline', inner: '<u>U</u>').tag('button', type: 'button', data_command: 'insertUnorderedList', inner: '•').tag('button', type: 'button', data_command: 'insertOrderedList', inner: '1.'))
$editor = tag('div', class: 'editor', contenteditable: 'true', inner: $value)
$hiddenInput = textarea(name: $this->name, class: 'hidden-value', inner: $value)
return tag('div', class: 'wysiwyg-container', inner: "$toolbar$editor$hiddenInput")
prop

%field_wysiwyg -> objColumns

line 19
将WYSIWYG字段的列作为对象访问,允许对字段的数据结构进行操作。
[$this->name]
view

script

line 21
该脚本通过处理按钮点击以执行命令,并在输入事件中更新隐藏的textarea与编辑器的HTML内容,从而启用WYSIWYG编辑器。
on('click', '.wysiwyg-container .toolbar button', (button, e) => {
	e.preventDefault()
	const command = button.dataset.command
	document.execCommand(command, false, null)
})

on('input', '.wysiwyg-container .editor', (editor) => {
	const container = editor.closest('.wysiwyg-container')
	const hiddenInput = container.querySelector('textarea.hidden-value')
	hiddenInput.value = editor.innerHTML
})
on('click', '.wysiwyg-container .editor a', (a) => window.open(a.href))

Functions

function

field($type, ...$args)

/phlo/resources/fields/field.phlo line 10
创建一个具有指定类型和附加参数的字段,使用phlo函数为字段生成唯一标识符。
phlo("field_$type", ...$args, type: $type)

我们使用必要的cookie来使该网站正常工作。在您的许可下,我们还使用分析工具来改善网站。