Custom create button not generating proper links for button to external component #255

Closed
opened 2018-03-30 00:23:22 +00:00 by cpaschen · 8 comments
cpaschen commented 2018-03-30 00:23:22 +00:00 (Migrated from github.com)

Steps to reproduce the issue

  • Have 2 different components:
    • Component 1 - com_kr_books_system - has the values to lookup/add
    • Component 2 - com_kr_books_reviews - has the custom field that looks up against component 1
  • Create a CUSTOM field and set:
    • table = '#__kr_books_system_review_cancel_reason'
    • component="com_kr_books_system"
    • view="reviews_cancel_reason"
    • views="reviews_cancel_reasons"
    • value_field="reason_name"
    • key_field="id"

Expected result

in /administrator/components/com_kr_books_reviews/models/fields/cancelreason.php in the getInput() function,

around line 85:

$button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_KR_BOOKS_REVIEWS_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;" 
href="index.php?option=com_kr_books_system&amp;view=reviews_cancel_reason&amp;layout=edit'.$ref.'" >
<span class="icon-new icon-white"></span></a>';

and around line 117:

var url = 'index.php?option=com_kr_books_system&view=reviews_cancel_reasons&task=reviews_cancel_reason.edit&id='+value+'".$refJ."';

Actual result

around line 85:

$button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_KR_BOOKS_REVIEWS_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
					href="index.php?option=com_kr_books_reviews&amp;view=reviews_cancel_reason&amp;layout=edit'.$ref.'" >
					<span class="icon-new icon-white"></span></a>';

and around line 117:

var url = 'index.php?option=com_kr_books_reviews&view=reviews_cancel_reasons&task=reviews_cancel_reason.edit&id='+value+'".$refJ."';

System information (as much as possible)

  • OS Name & Version: WAMP/LAMP
  • MySql Version: 5.5.56
  • Apache Version: 2.4.27
  • PHP Version: 7.1.9
  • Joomla Version: 3.8.6
  • JCB Version: 2.7.0
  • Browser: Chrome

Additional comments

It appears for some reason, that the component name isn't getting used as set in the custom field parameters and it is defaulting to the current component.

### Steps to reproduce the issue - Have 2 different components: - Component 1 - com_kr_books_system - has the values to lookup/add - Component 2 - com_kr_books_reviews - has the custom field that looks up against component 1 - Create a CUSTOM field and set: - table = '#__kr_books_system_review_cancel_reason' - component="com_kr_books_system" - view="reviews_cancel_reason" - views="reviews_cancel_reasons" - value_field="reason_name" - key_field="id" ### Expected result in /administrator/components/com_kr_books_reviews/models/fields/cancelreason.php in the getInput() function, around line 85: ``` $button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_KR_BOOKS_REVIEWS_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;" href="index.php?option=com_kr_books_system&amp;view=reviews_cancel_reason&amp;layout=edit'.$ref.'" > <span class="icon-new icon-white"></span></a>'; ``` and around line 117: `var url = 'index.php?option=com_kr_books_system&view=reviews_cancel_reasons&task=reviews_cancel_reason.edit&id='+value+'".$refJ."';` ### Actual result around line 85: ``` $button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_KR_BOOKS_REVIEWS_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;" href="index.php?option=com_kr_books_reviews&amp;view=reviews_cancel_reason&amp;layout=edit'.$ref.'" > <span class="icon-new icon-white"></span></a>'; ``` and around line 117: `var url = 'index.php?option=com_kr_books_reviews&view=reviews_cancel_reasons&task=reviews_cancel_reason.edit&id='+value+'".$refJ."';` ### System information (as much as possible) - OS Name & Version: WAMP/LAMP - MySql Version: 5.5.56 - Apache Version: 2.4.27 - PHP Version: 7.1.9 - Joomla Version: 3.8.6 - JCB Version: 2.7.0 - Browser: Chrome ### Additional comments It appears for some reason, that the component name isn't getting used as set in the custom field parameters and it is defaulting to the current component.

Hi, can you please provide the XML field definition that you wrote to build the custom field?

Hi, can you please provide the **XML field definition** that you wrote to build the custom field?
cpaschen commented 2018-03-30 02:26:35 +00:00 (Migrated from github.com)

Here's the xml field definition for the custom field. This is in the com_kr_books_reviews component:

<field 
	type="cancelreason" 
	name="cancelled_reason" 
	label="Reason why this review request was cancelled" 
	description="" 
	message="" 
	class="list_class" 
	multiple="false" 
	default="0" 
	required="" 
	validate="" 
	readonly="" 
	disabled="" 
	showon="" 
	onchange="" 
	extends="list" 
	button="true" 
	table="#__kr_books_system_reviews_cancel_reason" 
	component="com_kr_books_system" 
	view="reviews_cancel_reason" 
	views="reviews_cancel_reasons" 
	value_field="reason_name" 
	key_field="id" 
	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->loadObjectList();" 
	type_php_9="$options = array();" 
	type_php_10="if ($items)" 
	type_php_11="{" 
	type_php_12="\t$options[] = JHtml::_('select.option', '', 'Select a reason');" 
	type_php_13="\tforeach($items as $item)" 
	type_php_14="\t{" 
	type_php_15="\t\t$options[] = JHtml::_('select.option', $item->###ID###, $item->###CODE_TEXT###);" 
	type_php_16="\t}" 
	type_php_17="}" 
	type_php_18="" 
	type_php_19="return $options;" 
/>
Here's the xml field definition for the custom field. This is in the com_kr_books_reviews component: ``` <field type="cancelreason" name="cancelled_reason" label="Reason why this review request was cancelled" description="" message="" class="list_class" multiple="false" default="0" required="" validate="" readonly="" disabled="" showon="" onchange="" extends="list" button="true" table="#__kr_books_system_reviews_cancel_reason" component="com_kr_books_system" view="reviews_cancel_reason" views="reviews_cancel_reasons" value_field="reason_name" key_field="id" 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->loadObjectList();" type_php_9="$options = array();" type_php_10="if ($items)" type_php_11="{" type_php_12="\t$options[] = JHtml::_('select.option', '', 'Select a reason');" type_php_13="\tforeach($items as $item)" type_php_14="\t{" type_php_15="\t\t$options[] = JHtml::_('select.option', $item->###ID###, $item->###CODE_TEXT###);" type_php_16="\t}" type_php_17="}" type_php_18="" type_php_19="return $options;" /> ```

Okay I see the bug... will fix it in next release 👍

Okay I see the bug... will fix it in next release :+1:

Okay the patch is out, please test the latest staging branch to see if the issue is resolved at your side.

Okay the patch is out, please test the latest staging branch to see if the issue is resolved at your side.
cpaschen commented 2018-03-30 13:50:08 +00:00 (Migrated from github.com)

Yes. Works perfectly now.
Thanks!

Yes. Works perfectly now. Thanks!
cpaschen commented 2018-03-30 13:55:03 +00:00 (Migrated from github.com)

Actually, possibly responded too quickly.

I am getting an error once on that 'external' page (in the 'system' component) upon either saving a new entry or closing the form:

404 View not found [name, type, prefix]: reviews_assignment, html, kr_books_systemView

I haven't had a chance yet to track that down, but looks like it is somehow loosing it's referral location.

Actually, possibly responded too quickly. I am getting an error once on that 'external' page (in the 'system' component) upon either saving a new entry or closing the form: 404 View not found [name, type, prefix]: reviews_assignment, html, kr_books_systemView I haven't had a chance yet to track that down, but looks like it is somehow loosing it's referral location.

Hmmm this could be an issue. Will have to look at improving the whole referral concept. For now it seems like when targeting a external component, to remove referrals.

Hmmm this could be an issue. Will have to look at improving the whole referral concept. For now it seems like when targeting a external component, to remove referrals.

Okay please test, as I have update the concept to use the default return option if a external component is detected in the custom field. Hope this resolves the issue, let me know.

Okay please test, as I have update the concept to use the default return option if a external component is detected in the custom field. Hope this resolves the issue, let me know.
Sign in to join this conversation.
No Milestone
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#255
No description provided.