Database bindings

First off, I come from dreamweaver and I am very used to that kind of coding.
When I had set up a record set I could use those elements in the page to my liking.

Here in Wappler it’s a bit different I think…

I cannot find any code that represents the content of a recordset field.

There are generated tables. But the cel doesn’t have the field code in it. It is bound to the cell parameters.

When I place a paragraph and double click the text I see a binding button.

But when I place an image and want to set the source to a recordset field, I cannot find a data binding button.

So what is the wappler way of doing these things?

I guess I miss the freedom to use the fields data in the code editor and don’t understand where to find all the bindings to the fields of the server connect results.

Hope I made myself clear…?

If you want to set a dynamic src attribute just use the dynamic attributes. Select your image > add new dynamic attribute > images > image source and select the binding there using the data picker.

Same is valid for any kind of attributes for any element on the page - href, name, alt, title etc.

1 Like

I am not sure what you are asking in the rest of the post but maybe this will make some sense.

<td dmx-text="cost_reason"></td>

Is the same as

<td>{{cost_reason}}</td>

The table generator uses the first method for some reason. Quite often I have to change it in the code to be like the second option. Especially if I need to add a FA icon or make it a link.

2 Likes

Thnx @Teodor, glad those bindings can be found on every element possible.

Thnx @brad, yes that’s what I was looking for. That gives me more room for customizations!

2 Likes

Brad, do you know the correct php call to this value?

I use a php formula in which I need this variable value:
<tr class="<?php strtoupper ( substr ( {{customercode}}, 5, 1 ) ); ?>">

This {{customercode}} works outside of php but not between <?php ?>

Is there a notation I can use to get this value within the php tags?

PHP is evaluated on the server whereas the customer code is being evaluated by javascript in the browser once the API call has completed.

What I think you need is this added to your tr:

dmx-bind:class="customercode.substr(5,1).uppercase()"

Just be careful as dmx-bind:class replaces the whole list of classes. If you want to apply a specific class you would need:

dmx-class:someclass="expression that adds the class when true"
1 Like

Great! Thanks bpj. That works nicely.
Small typo: uppercase()

So this means that wappler organizes everything with javascript?

I was used to using php in recordsets/repeat regions in Dreamweaver

1 Like

oops!

Any server connect components/forms that you add to their page are called via javascript in the browser. You can do some PHP on-page but you would need to pre-fetch. This might be useful:

If you are in the early days of your project, I’d suggest seriously considering using the NodeJS server model. As well as having server-side bindings, you can access other functions like utilising sockets for real-time data

1 Like

Thanks bpj
Very helpful :pray: