fx_get_state(string $key): mixed
fx_set_state(string $key, mixed $value): mixed
fx_no_state(string $key): bool
fx_state(string $key, mixed $default_value = NULL): mixed
fx_set_state('foo', 'bar');
fx_text('foo = ' . fx_state('foo'));
if (fx_no_state('baz')) {
fx_set_state('baz', 'qux');
}
fx_text('baz = ' . fx_get_state('baz'));
$label
is treated as an ID.
fx_title(mixed $value): void
Header
fx_header(mixed $value): void
fx_header('Hello World');
fx_text(mixed $value): void
fx_plain_text(mixed $value): void
fx_plain_text('Hello world!');
fx_html(mixed $value): void
fx_html('<p>Hello <b>world</b>!</p>');
fx_json(mixed $value): void
fx_json(['message' => 'Hello world!']);
fx_dump(mixed $value): void
fx_dump(['message' => 'Hello world!']);
fx_image(string $url): void
fx_audio(string $url): void
fx_video(string $url): void
fx_table(array $array): void
fx_table([
(object) ['name' => 'Apple', 'price' => 1],
(object) ['name' => 'Banana', 'price' => 2],
(object) ['name' => 'Cherry', 'price' => 3],
]);
fx_csv_table(array $array): void
fx_csv_table([
['Name', 'Price'],
['Apple', 1],
['Banana', 2],
['Cherry', 3],
]);
fx_button(string $label): bool
if (fx_button('Click Me')) {
fx_set_state('clicked', true);
}
if (fx_state('clicked')) {
fx_text('You have clicked the button');
}
fx_text_button(string $label): bool
if (fx_text_button('Click Me')) {
fx_set_state('clicked', true);
}
if (fx_state('clicked')) {
fx_text('You have clicked the text button');
}
fx_button_group(array $buttons): ?string
$buttons
is treated as an ID.
$clicked = fx_button_group(['Button 1', 'Button 2', 'Button 3']);
if ($clicked) {
fx_set_state('clicked', $clicked);
}
fx_text('Clicked: ' . fx_state('clicked'));
fx_textbox(string $label, string $initial_value = ''): string
$name = fx_textbox('Name', 'John');
fx_text('Hello ' . $name . '!');
fx_textbox_s(string $label, string $value): string
fx_set_state(
'name',
fx_textbox_s('Name', fx_state('name', 'John'))
);
fx_text('Hello ' . fx_state('name') . '!');
fx_password(string $label, string $initial_value = ''): string
fx_password_s(string $label, string $value): string
$password = fx_password('Password');
fx_text('Password: ' . $password);
fx_number(string $label, number $initial_value = 0): number
fx_number_s(string $label, number $value): number
$number = fx_number('Number');
fx_text('Number: ' . $number);
fx_memo(string $label, string $initial_value = ''): string
fx_memo_s(string $label, string $value): string
$message = fx_memo('Message');
fx_plain_text($message);
fx_checkbox(string $label, bool $initial_checked = false): bool
fx_checkbox_s(string $label, bool $checked): bool
$agree = fx_checkbox('Agree');
fx_text('Agree: ' . ($agree ? 'yes' : 'no'));
fx_combobox(string $label, array $options, string $initial_selected = ''): string
fx_combobox_s(string $label, array $options, string $selected): string
$fruit = fx_combobox('Fruit', ['Apple', 'Banana', 'Cherry']);
fx_text('Fruit: ' . $fruit);
fx_multi_combobox(string $label, array $options, array $initial_selected = []): array
fx_multi_combobox_s(string $label, array $options, array $selected): array
$fruits = fx_multi_combobox('Fruits', ['Apple', 'Banana', 'Cherry']);
fx_text('Fruits: ' . implode(', ', $fruits));
fx_radio_group(string $label, array $options, string $initial_selected = ''): string
fx_radio_group_s(string $label, array $options, string $selected): string
$fruit = fx_radio_group('Fruit', ['Apple', 'Banana', 'Cherry']);
fx_text('Fruit: ' . $fruit);
fx_checkbox_group(string $label, array $options, array $initial_selected = []): array
fx_checkbox_group_s(string $label, array $options, array $selected): array
$fruit = fx_checkbox_group('Fruit', ['Apple', 'Banana', 'Cherry']);
fx_text('Fruit: ' . $fruit);
fx_same_line(number $count = 2): void
fx_button('Button 1');
fx_button('Button 2');
fx_same_line();
fx_begin_row()
fx_end_row()
fx_begin_column()
fx_end_column()
fx_begin_row();
fx_begin_column();
fx_text('Column 1');
fx_end_column();
fx_begin_column();
fx_text('Column 2');
fx_end_column();
fx_begin_column();
fx_text('Column 3');
fx_end_column();
fx_end_row();
fx_begin_tab(array $pages, string $initial_selected = ''): string
fx_begin_tab_s(array $pages, string $selected): string
$pages
is treated as an ID.
$page = fx_begin_tab(['Page 1', 'Page 2', 'Page 3'], 'Page 2');
switch ($page) {
case 'Page 1':
fx_text('Page 1 content here.');
break;
case 'Page 2':
fx_text('Page 2 content here.');
break;
case 'Page 3':
fx_text('Page 3 content here.');
break;
}
fx_end_tab();
fx_begin_dialog(): void
fx_end_dialog(): void
if (fx_state('show_dialog')) {
fx_begin_dialog();
fx_text('Dialog content here.');
if (fx_button('Close Dialog')) {
fx_set_state('show_dialog', false);
}
fx_end_dialog();
}
if (fx_button('Show Dialog')) {
fx_set_state('show_dialog', true);
}
fx_begin_form(): void
fx_end_form(): void
fx_begin_form();
$username = fx_textbox('Username');
$password = fx_password('Password');
if (fx_button('Login')) {
if ($username == 'admin' && $password == 'admin') {
fx_set_state('message', 'Login success.');
} else {
fx_set_state('message', 'Invalid username or password.');
}
}
fx_end_form();
fx_text(fx_state('message'));
fx_data_grid(array $columns, array $initial_rows = []): array
fx_data_grid_s(array $columns, array $rows): array
$columns
is treated as an ID.
$fruits = fx_data_grid(
['Name', 'Price'],
[
(object) ['Name' => 'Apple', 'price' => 1],
(object) ['Name' => 'Banana', 'price' => 2],
(object) ['Name' => 'Cherry', 'price' => 3],
]
);
fx_dump($fruits);
fx_begin_offcanvas()
fx_end_offcanvas()
if (fx_state('show_offcanvas')) {
fx_begin_offcanvas();
fx_text('Offcanvas content here.');
if (fx_button('Close Offcanvas')) {
fx_set_state('show_offcanvas', false);
}
fx_end_offcanvas();
}
if (fx_button('Show Offcanvas')) {
fx_set_state('show_offcanvas', true);
}
$count = fx_state('count', 0);
$text = fx_state('text', '');
fx_emit(<<<HTML
<button data-target="My Button">$count</button>
<input data-target="My Text Box">
<p>Count: $count</p>
<p>Text: $text</p>
HTML);
if (fx_event()->type == 'click' && fx_event()->target == 'My Button') {
fx_set_state('count', fx_state('count') + 1);
}
if (fx_event()->type == 'change' && fx_event()->target == 'My Text Box') {
fx_set_state('text', fx_event()->value);
}
fx_emit(mixed $content): void