Skip to content

Commit

Permalink
Example: Add example for the tab field
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-jaussaud committed Jan 14, 2025
1 parent 29cfc5c commit 1d07780
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
7 changes: 7 additions & 0 deletions example/register/sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@
'switch' => []
]
],
'tab' => [
'title' => 'Tab',
'path' => 'fields/tab',
'fields'=> [
'tab' => [ 'json' => true ],
]
],
'text' => [
'title' => 'Text',
'path' => 'fields/text',
Expand Down
98 changes: 98 additions & 0 deletions example/templates/fields/tab.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<h4>Example</h4>

<div class="tangible-settings-row">
<?= $fields->render_field('tab', [
'label' => 'Tab field',
'type' => 'tab',
'value' => $fields->fetch_value('tab'),
'tabs' => [
'tab-name-1' => [
'title' => 'Tab name 1',
'fields' => [
[
'label' => 'Text field',
'type' => 'text',
'name' => 'text-field'
],
[
'label' => 'Code field',
'type' => 'code',
'name' => 'code-field'
],
]
],
'tab-name-2' => [
'title' => 'Tab name 2',
'fields' => [
[
'label' => 'Color field',
'type' => 'color-picker',
'name' => 'color-field'
],
[
'label' => 'Number field',
'type' => 'number',
'name' => 'number-field'
],
]
]
]
]) ?>
</div>

<div class="tangible-settings-row">
<?php submit_button() ?>
</div>

<h4>Value</h4>

<?php tangible\see(
$fields->fetch_value('tab')
); ?>

<h4>Code</h4>

<pre>
<code>
$fields = tangible_fields();
<?php $plugin->render_registation_message(); ?>

echo $fields->render_field('name', [
'label' => 'Tab field',
'type' => 'tab',
'value' => $fields->fetch_value('name'),
'tabs' => [
'tab-name-1' => [
'title' => 'Tab name 1',
'fields' => [
[
'label' => 'Text field',
'type' => 'text',
'name' => 'text-field'
],
[
'label' => 'Code field',
'type' => 'code',
'name' => 'code-field'
],
]
],
'tab-name-2' => [
'title' => 'Tab name 2',
'fields' => [
[
'label' => 'Color field',
'type' => 'color-picker',
'name' => 'color-field'
],
[
'label' => 'Number field',
'type' => 'number',
'name' => 'number-field'
],
]
]
]
]);
</code>
</pre>

0 comments on commit 1d07780

Please sign in to comment.