Calc element not showing as database join label

chozma

Member
Hi guys,

I have a database join element that is pulling in a calc element as its label. However the calc element is not displaying in my dropdown list, I just get blanks for each option. If I view the table I can see the calc element spitting out the string as I would expect. o_O

To be more specific I have a table called mob with a database join element to a table called animal. I want the database join element to display the name and a user given id of the animal (two fields combined) in the dropdown and store the records id as its value.

I don't think the label concat function is an alternative option for me, as there are legit occasions when the animal doesn't have a name or a user given id. So I deemed a calc element the best way to produce exactly the formatting I want when there is no name or id.

Am I doing something wrong?

Thanks as always, :D

Hannah
x
 
I assume you've set "only calc on save" =no. The list view is then calculating "on the fly" and I assume the dbjon label is taking the value from the DB.
So you must make sure that every record in your animal table is edited/save once to store the calculated value in the DB (or set it with something like phpMyAdmin).

Or you can use the "Eval options" in "Advanced" tab of dbjoin element settings.
 
Thanks for your help Troester :D

I didn't think of that. Yes it does seem that the label is drawing the value from the DB and not generating on the fly. So I have it working as I want now.

I hadn't noticed the 'eval options' in the 'advanced' tab either. That might come in very handy for later.

Thanks again, I always appreciate your speedy help!
 
Did you fix it by setting "Calc on save only" to No, or by forcing the data for the calc in the table by editing and saving each record?

I didn't think setting "Calc on save only" to No would work, because although that would render the calc in the List display, the calc happens in PHP when rendering the calc element ... but the join is picking up it's label during the main getData() query prior to that.

-- hugh
 
I 'fixed' it by keeping 'Calc on save only' as No and amending my existing records using PHPMyAdmin so there was something already saved in the DB to be pulled out. I can see the text I would expect to see in the dropdown now and saving or amending records is updating the calc element and therefore dropdown as I would expect.

However, I've just hit on another interesting, associated (I think) problem. The dbjoin element has a validation on it to check the field isn't empty on submit. But when I select a value from the dropdown and fill in everything else and then save I am being told the form is not filled in correctly. I'm not sure it should do this?
 
Just to be sure, you aren't using the calc as the value for the join, just the label? The value is (hopefully) the PK of the table you are joining to?

-- hugh
 
Exactly, calc is just for the label and the value is the PK. Screenshot attached if that helps.
 

Attachments

  • Capture.PNG
    Capture.PNG
    8.7 KB · Views: 165
Hi guys,

Not sure where we've got to with this? Would you let me know if the issue of the validation not working is likely to be something I've done wrong/could do differently or if it is something you are looking into at your end,

Kind regards,

Hannah
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top