Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Display Label of Enum Value 23 Nov 2016 11:36 #14728

Hi Everyone,
From inside my forked grid view I would like to echo the Label of an Enum field (given its value). Essentually I am trying to create a grid column with the Enum Value displayed, but the Enum Label as hover text.

In my code below "Hello" needs to be replaced with the Enum Label. $row->validation just gives me the enum value.
<?php 
	$data = "<span class='hasPopover' data-content='Hello' data-placement='left'>".$row->validation."</span>";
	echo JDom::_('html.fly', array(
	'dataValue' => $data
));?>
On another generic question... is there a website about that explains JDom? What are the JDOM arguments/syntax? How do we actually modifiy it? Which folder it is stored? I find the JCook Docs on JDOM unclear.
Just call me Chris :)

Please Log in or Create an account to join the conversation.

Last edit: by organicwebs.

Display Label of Enum Value 23 Nov 2016 18:49 #14743

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
I am gonna work about the whole documentation of Cook this winter.

For getting the item of an enumeration, just get access to it with the index.
$list = XxxxHelperEnum::_('table_validation');
$item = $list[$row->validation];
$myLabel = $item['text'];

Or another way in line:
$myLabel = XxxxHelperEnum::_('table_validation')[$row->validation]['text'];

I think I should write some more code in the enumeration helper to access and work with the lists.
Getting the item by value
Getting the text

EDIT : It would had the advantage to handle basic errors because the code I give to you is raw. It do not prevents in case the value is empty, or the item not found in the list.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Last edit: by admin.

Display Label of Enum Value 23 Nov 2016 18:53 #14744

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Edited previous
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Display Label of Enum Value 23 Nov 2016 20:18 #14745

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
NEW UPGRADE

In the continuity of the enumerations feature, I modified the helper source code.
Now it is possible to achieve easily with :
$myLabel = XxxxHelperEnum::text('table_validation', $row->validation);

And for the whole item (array, not object):
$myItem = XxxxHelperEnum::item('table_validation', $row->validation);

The system is open for unlimited forks and now works in an instanced way. (Advanced customs)

I will explain widely all the code features in the documentations. For the moment, you can use easily for the basics.
Coding is now a piece of cake
The following user(s) said Thank You: organicwebs

Please Log in or Create an account to join the conversation.

Display Label of Enum Value 24 Nov 2016 14:24 #14747

Thanks Chef!

I haven't got it working yet - it is returning nothing for me at the moment.

Regarding "table_validation" - is that the table name in which the enum is inside? For me, my "validation" enum field is inside a table called "devices" - so should that be "table_devices"?
Just call me Chris :)

Please Log in or Create an account to join the conversation.

Display Label of Enum Value 24 Nov 2016 20:41 #14748

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Should be :
devices_validation

The function in the Helper is called '___devices_validation' and appears at the top of the class file.
Coding is now a piece of cake
The following user(s) said Thank You: organicwebs

Please Log in or Create an account to join the conversation.

Display Label of Enum Value 29 Nov 2016 02:44 #14762

Thanks Chef,
that make sence - I didn't try that :P

This works nicely for me in fork/views/devices/tmpl/default_grid.php ...
$myLabel = XxxxHelperEnum::_('devices_validation')[$row->validation]['text'];

But just so you know, this comes up empty for me ...
$myLabel = XxxxHelperEnum::text('devices_validation', $row->validation);
Just call me Chris :)

Please Log in or Create an account to join the conversation.

Display Label of Enum Value 01 Dec 2016 01:28 #14789

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Should be better now.

Fixed.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.069 seconds

This Component Generator is the REAL component generator. This tool is very easy to use and in a matter of minutes I was building a fully working extension. I was amazed with the end result... worth every cent...
Griiettner (JED)

         

Get Started