• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

placeholder for dropdown only return value,not label

samani

Member
hi
i have a simple dropdown element that has some velue/lable such as 1/A 2/B 3/C ....
i want get A or B or.... infact i want get label but it is return only value
i use these syntax :
Code:
$formModel->getElementData('registration___city');
'{registration___city}'
but in both syntax i get value of that dropdown element such as 1 or 2 ...
how to get label of dropdown selected?
i use these in php form plugin
 
Correct, you will only have the values available at that point. This is because the form itself only submits values. That's an HTML thing, not a Fabrik thing. Labels for dropdowns (and radios, and checkboxes) are only for display to the user, they don't get submitted with the form. So at that point, the labels are only stored in the settings of the element itself, they aren't in the submitted data. Later in the form processing, Fabrik will add the labels, during post-processing, so they are available for things like emails. But as it's a significant overhead to build all that rendered data, we don't do it during pre-processing (before the data is written to the table), as we don't need it at that point, and just want to get data written out as quickly as possible.

I pretty much always use joins rather than dropdowns if I'm going to need to do any processing of my own, as that makes getting labels for values a lot easier, it's just straight forward table lookups, rather than having to worry about Fabrik's internal data representations, and how we store labels for values.

However, you can get the labels, if you grab the element model. Something like ...

Code:
$elementModel = $formModel->getElement('yourtable___yourelement');
$label = $elementModel->getLabelForValue($value);

-- hugh
 
i see the dumped $formmodel (with jdump extension) and i can see the label of city and get with this syntax:
Code:
$formModel->emailData['registration___city']
it is work and return label of city drop down field
am i correct? is there anyproblem with do this?
I pretty much always use joins rather than dropdowns if I'm going to need to do any processing of my own, as that makes getting labels for values a lot easier
can you say me what syntax i can use to get label when you use join element?
 
Start of submission (onbeforeprocess)
Is it different or is there any tip? Maybe in future i want to change that.
 
OK, then you probably have something like a calc element on the form.

Typically, the $formModel->emailData array is not populated until 'onAfterProcess'. But certain elements (calc being one of them) will kick off the $formModel->getEmailData() method, causing all elements to render their formatted values, during the pre-processing phase.

The array name is a little inaccurate, for historical reasons. It's basically the rendered element data, more or less as it would appear in a list view, or details view ... or in an email. It was originally only used by the email plugin, back in Fabrik 1.x, hence the name.

So yeah, if that array is populated, go ahead and use it. Just note that if you ever remove whichever element is triggering the formatting process, that data may disappear and you'll have to trigger it yourself.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top