question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic Snippet Form problem

See original GitHub issue

Hi, At first, thanks for your efforts doing this great app.

Today I have an idea about to make Snippet Form dynamic, so I did something like this:

use App\Models\User;

$users = User::selectRaw('first_name as label, id as value')->get()->toArray();

$field_user = [
    'value' => '',
    'label' => 'User',
    'description' => 'Select a user.',
    'type' => 'select',
    'options' => $users, 
];

But as soon as I click the Snippet Form button, I get this white empty screen: image

I was trying to populate the User select from the DB, also I was planning to use the $field_user value as an input for a second DB query, so the chosen value for $field_user will customize the result of the second query!

I know maybe the feature was not design to work as I wanted, but when I think about it, supporting dynamic Snippet Form will make the possibilities endless for Tinkerun

Also another request: I will be grateful if you implemented a self-update feature in Tinkerun, so we always have the latest and greatest without checking Tinkerun website every week or so

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
billyctcommented, Jun 6, 2021

yes, I have not done the dynamic Snippet Form yet.

how about writing the dynamic data in the closure

for your case above:

$field_user = [
    'value' => '',
    'label' => 'User',
    'description' => 'Select a user.',
    'type' => 'select',
    'options' => function() {
		return User::selectRaw('first_name as label, id as value')->get()->toArray();
	}, 
];

with the closure, so I can just run code in the closure only with tinker for getting the dynamic data.

1reaction
billyctcommented, Jun 15, 2021

@diaafares yes, I think so. I will do it when I am free

Read more comments on GitHub >

github_iconTop Results From Across the Web

Programmatically adding html content snippets via JavaScript...
Programmatically adding html content snippets via JavaScript on to an Advanced Form Step (Dynamically adding instructions on to a form).
Read more >
Bootstrap Snippet Dynamic Form Fields - Add & Remove ...
Bootstrap example of Dynamic Form Fields - Add & Remove using HTML, Javascript, jQuery, and CSS. Snippet by cgrdavies.
Read more >
Dynamically add VSCode snippets from an extension
You can use SnippetString and a CompletionItemProvider to dynamically suggest snippets. Here is an example.
Read more >
How to Use Formidable Hooks
If you are attempting to use the same function or hook multiple times, you can't just duplicate the code and change field ids....
Read more >
20. Testing Dynamic Operations for a Form Question
Starting TaroWorks 6.5, you can now run the JavaScript code snippet on the form question to test the expected results.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found