How to populate a component's value option with a variable

I’m replacing a post I made days ago (deleted) and didn’t get any response. I will try to be more detailed.

I’ve researched a lot on this forum, but I haven’t found anything that helps me.
I purchased BSS to help me design the interfaces for my web systems.
As they are systems, they are not static. They depend on data that is stored in Database.

So far I’m very satisfied with the BSS, although I still mess up a bit, and I’ve already created interfaces for my systems with it.
However, there is something that bothered me a lot here. The interface is independent from the rest of the system and data.
I design the interface, export it and then embed the code to, read the database and update it.
But when I want to change something in the interface, I lose all the work of embedding code.

I read on this forum that you can use the “custom code” component, and even some attempts to explain its use. I tried to use it and managed to statically display data in pure display components, like the paragraph for example.

Now, in the components inside a Form, I haven’t figured out how to use it in a component “Text Input” or “Date And Time Input” for example.
On a date for example, how can I pre-populate this field with the value option, where the value must be a variable with the current date/time?
Or in a maintenance form, show a field already in the DB to be modified by the user. I would have to fill the “value” option with the DB content.

What I’ve done so far is, after exporting, I replace value="" with value="<? echo($fieldX); ?>". But I have to redo it again if I change the interface design.

Any solution for this? A working example would be interesting.

Thanks in advance.
Kind regards.

Good morning and Merry Christmas @carliedu

I can’t explain “how” to do this, but there are quite a few posts that can be found to help I believe.
It sounds to me like you’re in need of an “Export Script” that will allow you to add PHP to the files on export rather than having to do this manually after exporting. PHP isn’t allowed in the app, not sure if it ever will be although it’s been asked for quite a bit.

In the meantime, search the forums for “Export Script” and you should be able to find more information on it. Sometimes it’s not that it’s searched for, it’s that we don’t always know the right terms to start with lol. Export Script is above my head as I don’t do PHP and javascript etc. … yet … but there are plenty on the forums here that use them and should be able to help you now that we know exactly what you’re in need of.

There’s a brief primer on this in the Docs, but it’s not too detailed on it.

Hope that helps!

Just add the <? echo($fieldX); ?> to the value in bss.

While you are previewing it will just show the code, but once on a server running php it will work.

Try this:

  1. Add Text Input. Id: inp-date
  2. Add Javascript File: index.js
  3. Paste this code:

window.onload = function() {
// set date with variable example 1
let inpDate = document.getElementById(“inp-date”);
inpDate.value = new Date().toLocaleDateString();

// set date example 2
document.getElementById("inp-date").value = new Date().toLocaleDateString();


To load options from a database, you must use apis associated with it. Greetings

Thanks jo-r for your answer, and late merry christmas.

I have seen “Export Script” but this is the second phase of the integration. I’m still trying to solve the first step, which is to embed small codes (echos to display DB data) in the BSS, so that I don’t have to repeat for each export. That a lot of developers are asking the same, I can imagine.
About “Export Script” I already found a problem in Windows, but I put this question in a separete Topic.
Have a nice day.

Hi richards,
thanks for this tip.
I tried it out and it works.
As I answered to jo-r, now I’ll come to the second step of the PHP integration that is the “Export Script”.
I’ll try to report my integration progress with PHP (which also works for any other development languages) little by little, in this same thread, so that it can in future be part of documentation.