Feature Suggestion - subform in admin list view #248

Closed
opened 2018-03-19 19:15:19 +00:00 by mwweb · 20 comments
mwweb commented 2018-03-19 19:15:19 +00:00 (Migrated from github.com)

Steps to reproduce the issue

Create a Joomla Subform in JCB, then set the subform field to show on the admin list view, and filter.

This, of course, won't work since the subform is saves as a json, and the admin view has no way to know what the value is that you want populated.

Expected result

Actual result

I haven't exactly figured out the logistics yet. I've been testing with "hacking" the view and model to get it to decode the json, then output the result that I want to the view.

A thought for JCB, as subforms might start getting more and more popular, as you can save a lot of field data in a single field, is to have an option that if admin list and/or filter is selected, there is another option that show asking if this is a json. If yes, then a list shows with the fields options. IF you had, as an example, a subform with name, address, city, the list would show those options. If you selected name, then there would be a json decode for that field for the admin list, and since name was selected, name would be output to that column in the list.

This is just a thought, but I think would really expand some functionality.

System information (as much as possible)

  • OS Name & Version:
  • MySql Version:
  • Apache Version:
  • PHP Version:
  • Joomla Version:
  • JCB Version:
  • Browser:

Additional comments

### Steps to reproduce the issue Create a Joomla Subform in JCB, then set the subform field to show on the admin list view, and filter. This, of course, won't work since the subform is saves as a json, and the admin view has no way to know what the value is that you want populated. ### Expected result ### Actual result I haven't exactly figured out the logistics yet. I've been testing with "hacking" the view and model to get it to decode the json, then output the result that I want to the view. A thought for JCB, as subforms might start getting more and more popular, as you can save a lot of field data in a single field, is to have an option that if admin list and/or filter is selected, there is another option that show asking if this is a json. If yes, then a list shows with the fields options. IF you had, as an example, a subform with name, address, city, the list would show those options. If you selected name, then there would be a json decode for that field for the admin list, and since name was selected, name would be output to that column in the list. This is just a thought, but I think would really expand some functionality. ### System information (as much as possible) - OS Name & Version: - MySql Version: - Apache Version: - PHP Version: - Joomla Version: - JCB Version: - Browser: ### Additional comments

Well the idea was to be able to build a modal that display the data from the json in a table layout sort of the same way as in the sub form, just without edit options. Also no sorting and filtering will be available at first, but it could be extended later... the first would just be a dynamic modal with the table layout of the data in the subform.

What do you think, will this work for a start?

Well the idea was to be able to build a modal that display the data from the json in a table layout sort of the same way as in the sub form, just without edit options. Also no sorting and filtering will be available at first, but it could be extended later... the first would just be a dynamic modal with the table layout of the data in the subform. What do you think, will this work for a start?
mwweb commented 2018-03-19 20:30:42 +00:00 (Migrated from github.com)

Here's actually a sample of what I'm referring to.

In the sample, the column "Select a Resource/Class" and "Property Table" are custom dropdown lists in the item view, pulling the values from another view (settings and databases). In settings and databases the values are a subform. The view works good, it would just be nice to have an option to decode and display a value from the array to populate these columns. The filter dropdowns are populating correctly, just not working, which I think is because of the json not being decoded.

fields_sample

Here's actually a sample of what I'm referring to. In the sample, the column "Select a Resource/Class" and "Property Table" are custom dropdown lists in the item view, pulling the values from another view (settings and databases). In settings and databases the values are a subform. The view works good, it would just be nice to have an option to decode and display a value from the array to populate these columns. The filter dropdowns are populating correctly, just not working, which I think is because of the json not being decoded. ![fields_sample](https://user-images.githubusercontent.com/19194012/37620516-b6b901d2-2b79-11e8-9eb5-cde52c7827fd.png)

Give me some code examples... since it seems like we are thinking of two different concepts here.

  • I would like to display all the values from the subform, in the default admin list view, using a button. So when you click the button it loads a modal with a table of all the values.
  • You would like to display one row->one value from the subform (if I understand correctly)
Give me some code examples... since it seems like we are thinking of two different concepts here. - I would like to display all the values from the subform, in the default admin list view, using a button. So when you click the button it loads a modal with a table of all the values. - You would like to display one row->one value from the subform (if I understand correctly)
mwweb commented 2018-03-19 21:04:35 +00:00 (Migrated from github.com)

Your idea sounds interesting as well.

But what I was thinking is instead of this code below

<td class="hidden-phone"> <?php echo $this->escape($item->resourcetypes_name); ?> </td> <td class="hidden-phone"> <?php echo $this->escape($item->proptable_name); ?> </td>
It would json_decode, then output the results. From my initial example, if resourcetypes_name had name, address, city, and I wanted the site, it could be specified.

Your idea sounds interesting as well. But what I was thinking is instead of this code below ` <td class="hidden-phone"> <?php echo $this->escape($item->resourcetypes_name); ?> </td> <td class="hidden-phone"> <?php echo $this->escape($item->proptable_name); ?> </td> ` It would json_decode, then output the results. From my initial example, if resourcetypes_name had name, address, city, and I wanted the site, it could be specified.

Yes but what if there is ten rows?

Yes but what if there is ten rows?
mwweb commented 2018-03-19 21:21:11 +00:00 (Migrated from github.com)

If, as in the example below, each row would have the different value when it outputs the row data.

For example, at least in my example, the json is stored in a separate table, and the view has a custom field doing the lookup. If the json was:

{
  "resource0": {
    "recid": "1",
    "name": "name1",
    "address": "123 front street",
    "city": "seattle"
  },
  "resource1": {
    "recid": "2",
    "name": "name2",
    "address": "123 front street",
    "city": "new york"
  },
  "resource2": {
    "recid": "3",
    "name": "name3",
    "address": "123 front street",
    "city": "chicago"
  },
  "resource3": {
    "recid": "4",
    "name": "name4",
    "address": "123 front street",
    "city": "houston"
  },
  "resource4": {
    "recid": "5",
    "name": "name5",
    "address": "123 front street",
    "city": "tampa"
  }
}

then since it's a custom field, it is populating the value set in the custom field, in this case, recid. So, in each row for resource, there is a reference to recid: 1, 2, 3, 4, 5, etc.

A json_decode would decode that linked fields value, find recid=2, as an example, then output new york in the row, since I would have set city as the value I wanted returned.

In order for that feature to work, the subform would need to have a unique identifier.

If, as in the example below, each row would have the different value when it outputs the row data. For example, at least in my example, the json is stored in a separate table, and the view has a custom field doing the lookup. If the json was: ```json { "resource0": { "recid": "1", "name": "name1", "address": "123 front street", "city": "seattle" }, "resource1": { "recid": "2", "name": "name2", "address": "123 front street", "city": "new york" }, "resource2": { "recid": "3", "name": "name3", "address": "123 front street", "city": "chicago" }, "resource3": { "recid": "4", "name": "name4", "address": "123 front street", "city": "houston" }, "resource4": { "recid": "5", "name": "name5", "address": "123 front street", "city": "tampa" } } ``` then since it's a custom field, it is populating the value set in the custom field, in this case, recid. So, in each row for resource, there is a reference to recid: 1, 2, 3, 4, 5, etc. A json_decode would decode that linked fields value, find recid=2, as an example, then output new york in the row, since I would have set city as the value I wanted returned. In order for that feature to work, the subform would need to have a unique identifier.

I still do not understand.... lets start again.

  • The admin view has a subform that is saved in one column/field in the DB
  • When we retrieve a list of items that has been created with that admin view, each row has a field with the subform values in json format
  • That json (subform field) has a whole form of values basically, since it has rows and columns.
  • Normally that would translate to, to many values to display in one field.

Start explaining your idea from this background, so I can exactly understand how it relates to these expected realities. Meaning do we inject these rows into the exiting rows.. do we add JavaScript/Ajax that display these values based on and item selection... how do you deal with the table (subform json) in each row?

My suggestion was to in that field/subform place we add a button, which if clicked loads the table/subform values in a modal/popup basically looking exactly like the subform just without the option to edit and move the rows around.

I understand the subform format and how the JSON looks and stuff... to me the going from on field to a table is where we need to do the work, and still preserve the integrity of the Joomla core implementation.

I still do not understand.... lets start again. - The admin view has a subform that is saved in one column/field in the DB - When we retrieve a list of items that has been created with that admin view, each row has a field with the subform values in json format - That json (subform field) has a whole form of values basically, since it has rows and columns. - Normally that would translate to, to many values to display in one field. Start explaining your idea from this background, so I can exactly understand how it relates to these expected realities. Meaning do we inject these rows into the exiting rows.. do we add JavaScript/Ajax that display these values based on and item selection... how do you deal with the table (subform json) in each row? My suggestion was to in that field/subform place we add a button, which if clicked loads the table/subform values in a modal/popup basically looking exactly like the subform just without the option to edit and move the rows around. I understand the subform format and how the JSON looks and stuff... to me the going from on field to a table is where we need to do the work, and still preserve the integrity of the Joomla core implementation.
mwweb commented 2018-03-19 22:33:49 +00:00 (Migrated from github.com)

We're definitely on different ideas here. Let's think of it this way.

Table 1 field: name, subform called details (fields recid, name, address, city)

Table 2 fields: name, custom field with city as the text and recid as the value.

The custom field in table 2 it's doing a json_decode to get the data.

In table 1 the subform will of course be a json. But in table 2 the value saved to the field, if done correctly, would be the recid.

In the table list i guess it would be more of a cross table lookup, taking recid, cross referencing the decoded subform, returning the set text field.

We're definitely on different ideas here. Let's think of it this way. Table 1 field: name, subform called details (fields recid, name, address, city) Table 2 fields: name, custom field with city as the text and recid as the value. The custom field in table 2 it's doing a json_decode to get the data. In table 1 the subform will of course be a json. But in table 2 the value saved to the field, if done correctly, would be the recid. In the table list i guess it would be more of a cross table lookup, taking recid, cross referencing the decoded subform, returning the set text field.

SO you want to have a custom field that gets its values from another subform, well we do not need to change JCB to do that, it can already do that.

That is if I understand correctly, you want a custom field that populates from a subfrom in another table. JCB can already do that with custom fields. You will just need to know how to write the PHP and it can work.

Here is how we are doing it in JCB with the conditional fields in the admin view.

<field 
	type="targetfields" <-- custom field
	name="target_field" 
	label="Target Field/s" 
	description="Select the target field/s." 
	class="fieldMedium" 
	multiple="true" 
	default="" 
	required="true" 
	readonly="" 
	disabled="" 
	extends="list" 
	table="#__###component###_field" 
	component="com_###component###" 
	view="field" 
	views="fields" 
	value_field="name" 
	key_field="id" 
	type_php_1="// load the db opbject
		$db = JFactory::getDBO();		
		// get the input from url
		$jinput = JFactory::getApplication()->input;
		// get the id
		$ID = $jinput->getInt('id', 0);
		// rest the fields ids
		$fieldIds = array();
		if (is_numeric($ID) && $ID >= 1)
		{
			// get the admin view ID
			$adminView = ###Component###Helper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view');
		}
		else
		{
			// get the admin view ID
			$adminView = $jinput->getInt('refid', 0);
		}
		if (is_numeric($adminView) && $adminView >= 1)
		{
			// get all the fields linked to the admin view
			if ($addFields = ###Component###Helper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields'))
			{
				if (###Component###Helper::checkJson($addFields))
				{
					$addFields = json_decode($addFields, true);
					if (###Component###Helper::checkArray($addFields))
					{
						foreach($addFields as $addField)
						{
							if (isset($addField['field']))
							{
								$fieldIds[] = (int) $addField['field'];
							}
						}
					}
				}
			}
		}
		$query = $db->getQuery(true);
		$query->select($db->quoteName(array('a.id','a.name'),array('id','name')));
		$query->from($db->quoteName('#__###component###_field', 'a'));
		$query->where($db->quoteName('a.published') . ' >= 1');
		// filter by fields linked
		if (###Component###Helper::checkArray($fieldIds))
		{
			// only load these fields
			$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')');
		}
		$query->order('a.name ASC');
		$db->setQuery((string)$query);
		$items = $db->loadObjectList();
		$options = array();
		if ($items)
		{
			foreach($items as $item)
			{
				$options[] = JHtml::_('select.option', $item->id, $item->name);
			}
		}
		
		return $options;" 
/>

Let me know if this is what you are trying to do.

SO you want to have a custom field that gets its values from another subform, well we do not need to change JCB to do that, it can already do that. That is if I understand correctly, you want a custom field that populates from a subfrom in another table. JCB can already do that with custom fields. You will just need to know how to write the PHP and it can work. Here is how we are doing it in JCB with the conditional fields in the admin view. ```xml <field type="targetfields" <-- custom field name="target_field" label="Target Field/s" description="Select the target field/s." class="fieldMedium" multiple="true" default="" required="true" readonly="" disabled="" extends="list" table="#__###component###_field" component="com_###component###" view="field" views="fields" value_field="name" key_field="id" type_php_1="// load the db opbject $db = JFactory::getDBO(); // get the input from url $jinput = JFactory::getApplication()->input; // get the id $ID = $jinput->getInt('id', 0); // rest the fields ids $fieldIds = array(); if (is_numeric($ID) && $ID >= 1) { // get the admin view ID $adminView = ###Component###Helper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view'); } else { // get the admin view ID $adminView = $jinput->getInt('refid', 0); } if (is_numeric($adminView) && $adminView >= 1) { // get all the fields linked to the admin view if ($addFields = ###Component###Helper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields')) { if (###Component###Helper::checkJson($addFields)) { $addFields = json_decode($addFields, true); if (###Component###Helper::checkArray($addFields)) { foreach($addFields as $addField) { if (isset($addField['field'])) { $fieldIds[] = (int) $addField['field']; } } } } } } $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id','a.name'),array('id','name'))); $query->from($db->quoteName('#__###component###_field', 'a')); $query->where($db->quoteName('a.published') . ' >= 1'); // filter by fields linked if (###Component###Helper::checkArray($fieldIds)) { // only load these fields $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); } $query->order('a.name ASC'); $db->setQuery((string)$query); $items = $db->loadObjectList(); $options = array(); if ($items) { foreach($items as $item) { $options[] = JHtml::_('select.option', $item->id, $item->name); } } return $options;" /> ``` Let me know if this is what you are trying to do.
mwweb commented 2018-03-20 08:06:08 +00:00 (Migrated from github.com)

That's not it. Please let me try this again.

In the following screenshot, "Select a Resource/Class" is a custom field, with the following code, which populates perfectly fine:

	/**
	 * Method to get a list of options for a list input.
	 *
	 * @return	array		An array of JHtml options.
	 */
	public function getOptions()
	{
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select($db->quoteName(array('a.propclasses','a.name'),array('propclasses','resourcetypes_name')));
		$query->from($db->quoteName('#__ipals_setting', 'a'));
		$query->where($db->quoteName('a.published') . ' = 1');
		$query->order('a.name ASC');
		$db->setQuery((string)$query);
		$items = $db->loadResult();
		$jsonObj = json_decode($items,true);
		$options = array();
		if ($items)
		{
			$options[] = JHtml::_('select.option', '', 'Select an option');
			foreach($jsonObj as $item)
			{
				$options[] = JHtml::_('select.option', $item['recid'], $item['propclasslabel']);
			}
		}
		return $options;
	}

The stored data in the table for the resource field is 2, which from the dropdown (list) is the value for "Agency".

field

In the next image, you will see the admin list view, which shows the record I was working on as the first record in the list. JCB is populating the filter dropdown on the left if the values, as you can see. I have checked the code, and the list corresponds to the custom field in the item view:

fields

list_resource-filter

The issue is that in the "Select a Resource/Class" column of the list view, the column is blank, even though there is a value present in the db field.

That's not it. Please let me try this again. In the following screenshot, "Select a Resource/Class" is a custom field, with the following code, which populates perfectly fine: ``` /** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ public function getOptions() { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.propclasses','a.name'),array('propclasses','resourcetypes_name'))); $query->from($db->quoteName('#__ipals_setting', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); $query->order('a.name ASC'); $db->setQuery((string)$query); $items = $db->loadResult(); $jsonObj = json_decode($items,true); $options = array(); if ($items) { $options[] = JHtml::_('select.option', '', 'Select an option'); foreach($jsonObj as $item) { $options[] = JHtml::_('select.option', $item['recid'], $item['propclasslabel']); } } return $options; } ``` The stored data in the table for the resource field is 2, which from the dropdown (list) is the value for "Agency". ![field](https://user-images.githubusercontent.com/19194012/37642204-8a4cffd0-2bd9-11e8-840a-19097ef27000.png) In the next image, you will see the admin list view, which shows the record I was working on as the first record in the list. JCB is populating the filter dropdown on the left if the values, as you can see. I have checked the code, and the list corresponds to the custom field in the item view: ![fields](https://user-images.githubusercontent.com/19194012/37642549-bb8adb0c-2bda-11e8-9b67-c0ff7b387312.png) ![list_resource-filter](https://user-images.githubusercontent.com/19194012/37642559-c3d1a156-2bda-11e8-97f1-dec1598d9109.png) The issue is that in the "Select a Resource/Class" column of the list view, the column is blank, even though there is a value present in the db field.
mwweb commented 2018-03-20 08:15:20 +00:00 (Migrated from github.com)

I guess i didn't really explain it well. The stored data in that column is a numerical value, which is referencing a name in a subform. The filter is doing it right, or so it seems, but not the column in the view.

I guess i didn't really explain it well. The stored data in that column is a numerical value, which is referencing a name in a subform. The filter is doing it right, or so it seems, but not the column in the view.
mwweb commented 2018-03-22 19:17:00 +00:00 (Migrated from github.com)

Did this make a bit more sense?

Did this make a bit more sense?

Can you give me the code in the model, as this does not look right, there should be a value.

Can you give me the code in the model, as this does not look right, there should be a value.

Also the XML of the custom field if you please.

Also the XML of the custom field if you please.
mwweb commented 2018-03-22 19:58:42 +00:00 (Migrated from github.com)

There are actually 2 fields that are doing the exact same thing, but here is the code from the one:

From the model:

		// [Interpretation 8470] From the ipals_setting table.
		$query->select($db->quoteName('g.name','resourcetypes_name'));
		$query->join('LEFT', $db->quoteName('#__ipals_setting', 'g') . ' ON (' . $db->quoteName('a.resourcetypes') . ' = ' . $db->quoteName('g.propclasses') . ')');

This is from the custom field:

	public function getOptions()
	{
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select($db->quoteName(array('a.propclasses','a.name'),array('propclasses','resourcetypes_name')));
		$query->from($db->quoteName('#__ipals_setting', 'a'));
		$query->where($db->quoteName('a.published') . ' = 1');
		$query->order('a.name ASC');
		$db->setQuery((string)$query);
		$items = $db->loadResult();
		$jsonObj = json_decode($items,true);
		$options = array();
		if ($items)
		{
			$options[] = JHtml::_('select.option', '', 'Select an option');
			foreach($jsonObj as $item)
			{
				$options[] = JHtml::_('select.option', $item['recid'], $item['propclasslabel']);
			}
		}
		return $options;
	}

Lastly, here is the custom field from the XML in the JCB field (before compile):

<field 
	type="resourcetypes" 
	name="resourceTypes" 
	label="Select a Resource/Class" 
	description="" 
	class="list_class" 
	multiple="false" 
	default="" 
	required="" 
	readonly="" 
	disabled="" 
	showon="" 
	onchange="" 
	extends="list" 
	button="true" 
	table="#__###component###_setting" 
	component="com_###component###" 
	view="setting" 
	views="settings" 
	value_field="name" 
	key_field="propclasses" 
	type_php_1="$db = JFactory::getDBO();" 
	type_php_2="$query = $db->getQuery(true);" 
	type_php_3="$query->select($db->quoteName(array('a.###ID###','a.###TEXT###'),array('###ID###','###CODE_TEXT###')));" 
	type_php_4="$query->from($db->quoteName('###TABLE###', 'a'));" 
	type_php_5="$query->where($db->quoteName('a.published') . ' = 1');" 
	type_php_6="$query->order('a.###TEXT### ASC');" 
	type_php_7="$db->setQuery((string)$query);" 
	type_php_8="$items = $db->loadResult();" 
	type_php_9="$jsonObj = json_decode($items,true);" 
	type_php_10="$options = array();" 
	type_php_11="if ($items)" 
	type_php_12="{" 
	type_php_13="\t$options[] = JHtml::_('select.option', '', 'Select an option');" 
	type_php_14="\tforeach($jsonObj as $item)" 
	type_php_15="\t{" 
	type_php_16="\t\t$options[] = JHtml::_('select.option', $item['recid'], $item['propclasslabel']);" 
	type_php_17="\t}" 
	type_php_18="}" 
	type_php_19="" 
	type_php_20="return $options;" 
/>
There are actually 2 fields that are doing the exact same thing, but here is the code from the one: From the model: ```php // [Interpretation 8470] From the ipals_setting table. $query->select($db->quoteName('g.name','resourcetypes_name')); $query->join('LEFT', $db->quoteName('#__ipals_setting', 'g') . ' ON (' . $db->quoteName('a.resourcetypes') . ' = ' . $db->quoteName('g.propclasses') . ')'); ``` This is from the custom field: ```php public function getOptions() { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->quoteName(array('a.propclasses','a.name'),array('propclasses','resourcetypes_name'))); $query->from($db->quoteName('#__ipals_setting', 'a')); $query->where($db->quoteName('a.published') . ' = 1'); $query->order('a.name ASC'); $db->setQuery((string)$query); $items = $db->loadResult(); $jsonObj = json_decode($items,true); $options = array(); if ($items) { $options[] = JHtml::_('select.option', '', 'Select an option'); foreach($jsonObj as $item) { $options[] = JHtml::_('select.option', $item['recid'], $item['propclasslabel']); } } return $options; } ``` Lastly, here is the custom field from the XML in the JCB field (before compile): ```xml <field type="resourcetypes" name="resourceTypes" label="Select a Resource/Class" description="" class="list_class" multiple="false" default="" required="" readonly="" disabled="" showon="" onchange="" extends="list" button="true" table="#__###component###_setting" component="com_###component###" view="setting" views="settings" value_field="name" key_field="propclasses" type_php_1="$db = JFactory::getDBO();" type_php_2="$query = $db->getQuery(true);" type_php_3="$query->select($db->quoteName(array('a.###ID###','a.###TEXT###'),array('###ID###','###CODE_TEXT###')));" type_php_4="$query->from($db->quoteName('###TABLE###', 'a'));" type_php_5="$query->where($db->quoteName('a.published') . ' = 1');" type_php_6="$query->order('a.###TEXT### ASC');" type_php_7="$db->setQuery((string)$query);" type_php_8="$items = $db->loadResult();" type_php_9="$jsonObj = json_decode($items,true);" type_php_10="$options = array();" type_php_11="if ($items)" type_php_12="{" type_php_13="\t$options[] = JHtml::_('select.option', '', 'Select an option');" type_php_14="\tforeach($jsonObj as $item)" type_php_15="\t{" type_php_16="\t\t$options[] = JHtml::_('select.option', $item['recid'], $item['propclasslabel']);" type_php_17="\t}" type_php_18="}" type_php_19="" type_php_20="return $options;" /> ```

Okay now I see... this will not work, as I started to make the tutorial I realized what you really are doing here and that will not work at this time.

type_php_9="$jsonObj = json_decode($items,true);"

Is where is all goes wrong :) or right... depending on who you ask. Since the value saved to the database is $item['recid'] and the key used to load the value in the list view is key_field="propclasses" but the field name is resourcetypes it can not connect the values accurately. Since you value is hidden in JSON it is sort of impossible for JCB to remap this. Convention is everything, and to build things that works we must try avoid these kind of issues. Mostly because of how c++ works and therefore how mySql works, and therefore how Joomla works and therefore how JCB works.

You can still make this work but with some extra custom code in the admin view->Add PHP (getItems Method - before translation fix & decryption).

foreach($items as $item)
{
	$item->resourcetypes = [[[Component]]]Helper::getPropclasslabel($item->resourcetypes);
}

Then in the helper class you create a public getPropclasslabel method that search for propclass label based on the recid since it is that value that is found in the database.

I must tell you to build JCB to do this via the UI is not going to happen soon, there is just to many pitfalls and edge case that is going to jump up. So it is custom code, but at least inside the JCB custom code area.

Okay now I see... this will not work, as I started to make the tutorial I realized what you really are doing here and that will not work at this time. ``` type_php_9="$jsonObj = json_decode($items,true);" ``` Is where is all goes wrong :) or right... depending on who you ask. Since the value saved to the database is `$item['recid']` and the key used to load the value in the list view is `key_field="propclasses"` but the field name is `resourcetypes` it can not connect the values accurately. Since you value is hidden in JSON it is sort of impossible for JCB to remap this. Convention is everything, and to build things that works we must try avoid these kind of issues. Mostly because of how c++ works and therefore how mySql works, and therefore how Joomla works and therefore how JCB works. You can still make this work but with some extra custom code in the **admin view**->_Add PHP (getItems Method - before translation fix & decryption)_. ```php foreach($items as $item) { $item->resourcetypes = [[[Component]]]Helper::getPropclasslabel($item->resourcetypes); } ``` Then in the helper class you create a public getPropclasslabel method that search for propclass label based on the recid since it is that value that is found in the database. I must tell you to build JCB to do this via the UI is not going to happen soon, there is just to many pitfalls and edge case that is going to jump up. So it is custom code, but at least inside the JCB custom code area.

Sorry just remove comments that were unrelated 👍

Sorry just remove comments that were unrelated :+1:
ro-ot commented 2018-03-24 16:19:33 +00:00 (Migrated from github.com)

@Llewellynvdm our original idea seems great 🎉

I think the problem with this issue @mwweb is experiencing is due to the compiler removing the subform field from list view. In the Fields class on line 2415 subform and repeatable fields are not being loaded.

So @mwweb the short answer is JCB does not allow those field in the list view at this time 😉

But if @Llewellynvdm adds the suggestion made here of allow subfrom fields in the list view, then think can get interesting 😆

@Llewellynvdm our original idea seems great :tada: I think the problem with this issue @mwweb is experiencing is due to the compiler removing the subform field from list view. In the [Fields class](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/helpers/compiler/c_Fields.php) on line [2415](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/helpers/compiler/c_Fields.php#L2415) `subform` and `repeatable` fields are not being loaded. So @mwweb the short answer is JCB does not allow those field in the list view at this time :wink: But if @Llewellynvdm adds the suggestion made here of allow subfrom fields in the list view, then think can get interesting :satisfied:

Not so sure, the field that is being targeted here is a custom field, so I don't think it is the problem that the field is not being added.

Yes I think we can add the idea to manage the display of the subform and repeatable fields. But what @mwweb is trying to do is some crazy gymnastics that will require some custom code, maybe even direct replacement custom code.

Not so sure, the field that is being targeted here is a custom field, so I don't think it is the problem that the field is not being added. Yes I think we can add the idea to manage the display of the subform and repeatable fields. But what @mwweb is trying to do is some crazy gymnastics that will require some custom code, maybe even direct replacement custom code.
ro-ot commented 2018-06-05 14:27:30 +00:00 (Migrated from github.com)

JCB and all its projects are leaving gitHub... this is going to take some time since JCB/VDM is so integrated with github,

The new address is https://gitlab.com/jcb-repos/Joomla-Component-Builder.

JCB and all its projects are leaving gitHub... this is going to take some time since JCB/VDM is so integrated with github, The new address is [https://gitlab.com/jcb-repos/Joomla-Component-Builder](https://gitlab.com/jcb-repos/Joomla-Component-Builder).
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#248
No description provided.