Replace value of let statement in another formula
Hiya
I'm setting up a global style system for our database. I have this formula for a button (created using a formula field):
let label := "";
let styleSheet := CSS;
let htmlString := "
<style>" + styleSheet + "</style>
<div class=""ca-btn info"">" + label + "</div>" + "";
html(htmlString)
I can then call on it in another table by reference the system table and field name. I'd like to be able to specify the button text, but I can't get it to work.
I've tried
let label := "new label text";
'Formula Field'
And also the other way around (formula first, let statement next). But, not happening.
So, is it possible to do, somehow?
5 replies
-
Alternatively, is there a way to show the formula label in the formula itself?
-
Why not just use the formula field itself... and whatever you need to do when the "button" is clicked.. goes into the formula's on click event..
-
Hi Mconneen
Thats what I'm doing. So basically I have a system settings table which holds the CSS and global components (buttons, header styles etc). My having it in this one location, it makes it easy for me to change the look of something and have it happen globally.
At the moemnt though, I have to have a formula field for every button, even though they have the same style, because I can't figure out how to have just one formula in the system settings for the button, and then change the text inside it
As you can see in the screenshot, I have a blue button design. I have around 18 variations of this where the only thing that changes (besides the on click function) is the text in the box. In some cases, I use the same button/text on multiple pages - others it only appears once.
With something like the round close button, this isn't an issue, becaue it is the same on every page. So, I have it once in my systems table, and select it in a formula field wherever it needs to appear.
So, for the blue buttons, ideally I'd like to have just a single formula in the systems table for that blue button. I'd like to be able to select it the same way I do the close record button... but I need to be able to change the text of the button.
I don't want to put the html formula into every button formula individually, as it means if I need to make any changes to the html structure of the button down the road, I'd have to do it on every single button (whereas the close button I'd only have to do on the formula in the system table).
Does that make sense?
I was hoping I could use the following in the formula of the button in the systems table: let label := ""
and then override when I select the formula in a formula in another table... but every way I've tried doesn't work. Which is why I'm wondering if its possible or not?
Also, if I was able to use the name of the formula field in the formula itself, that would be great. Like, just something along the lines of thisFieldName() I guess? That was probably very, very wrong structure but you get the idea.
wherever I use it.
-
@Sarah,
I think I follow you.. (and am a bit too lazy to code it out right now)... I am not aware that Ninox supports "reflection" or "introspection" like other languages.. so I think your settings table would have to have columns for..
Theme,Form,Button ID, Button Text, Button CSS
Then.. within each formula .. you can look up what you need.. as you know what form and what formula you are on and dynamically build out the html string..
-
Hmm... Okay, I follow you... I'll see how I go.
Thanks!
Content aside
- 5 yrs agoLast active
- 5Replies
- 1949Views