GetItems Method is unable to render html in list view #775

Closed
opened 2021-07-08 00:25:29 +00:00 by philecom · 3 comments
philecom commented 2021-07-08 00:25:29 +00:00 (Migrated from github.com)

Steps to reproduce the issue

Create admin view with a text field with name "receiptbtn"
Under the PHP tab in the jcb admin view add this code under "Add PHP (getItems Method - after all) *" option.

  `foreach ($items as $nr => &$item){
       	$item->receiptbtn = "<input type='text' id=''.$item->id.'' value=''.$item->fee.'' style='display:inline-block; width: 50px;' placeholder='Enter amount paid'/> <button type='button' class='btn btn-success btn-xs'>Send Receipt</button>";
   }`

screenshot-app onuafrancisschool com-2021 07 07-18_00_04

Save, compile, install and test.

Expected result

The admin view is supposed to have an item with a button and an input field on the list. like the one in the photo.
screenshot-app onuafrancisschool com-2021 07 07-23_42_03

Actual result

Instead, it strips all the httml tags and displays only the button label. as seen below.
screenshot-app onuafrancisschool com-2021 07 07-18_00_56

System information (as much as possible)

OS Name & Version: Linux business39.web-hosting.com 2.6.32-954.3.5.lve1.4.82.el6.x86_64
MySql Version: 10.3.28-MariaDB-log-cll-lve
Apache Version: Apache
PHP Version: 7.3.28
Joomla Version: Joomla! 3.9.28 Stable
JCB Version: Version: 2.12.9
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0

Additional comments

### Steps to reproduce the issue Create admin view with a text field with name "receiptbtn" Under the PHP tab in the jcb admin view add this code under "Add PHP (getItems Method - after all) *" option. `foreach ($items as $nr => &$item){ $item->receiptbtn = "<input type='text' id=''.$item->id.'' value=''.$item->fee.'' style='display:inline-block; width: 50px;' placeholder='Enter amount paid'/> <button type='button' class='btn btn-success btn-xs'>Send Receipt</button>"; }` ![screenshot-app onuafrancisschool com-2021 07 07-18_00_04](https://user-images.githubusercontent.com/3121292/124844362-9b0d9300-df83-11eb-9bfd-9cfaf994bbac.png) Save, compile, install and test. ### Expected result The admin view is supposed to have an item with a button and an input field on the list. like the one in the photo. ![screenshot-app onuafrancisschool com-2021 07 07-23_42_03](https://user-images.githubusercontent.com/3121292/124844444-cbedc800-df83-11eb-8cf2-6b5c74943b37.png) ### Actual result Instead, it strips all the httml tags and displays only the button label. as seen below. ![screenshot-app onuafrancisschool com-2021 07 07-18_00_56](https://user-images.githubusercontent.com/3121292/124844480-e6c03c80-df83-11eb-933a-a68af11a8740.png) ### System information (as much as possible) OS Name & Version: Linux business39.web-hosting.com 2.6.32-954.3.5.lve1.4.82.el6.x86_64 MySql Version: 10.3.28-MariaDB-log-cll-lve Apache Version: Apache PHP Version: 7.3.28 Joomla Version: Joomla! 3.9.28 Stable JCB Version: Version: 2.12.9 Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0 ### Additional comments

There is a method called escape that by default triggers on all fields.

To turn this off you will need to add property to your field, check out this tutorial: https://github.com/vdm-io/Joomla-Component-Builder/wiki/027-How-to-ensure-that-a-field-is-not-escaped-when-added-to-list-views

There is a method called [escape](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/views/admin_views/view.html.php#L309) that by default triggers on all fields. To turn this off you will need to add property to your field, check out this tutorial: https://github.com/vdm-io/Joomla-Component-Builder/wiki/027-How-to-ensure-that-a-field-is-not-escaped-when-added-to-list-views

Next you must in the list view look at the field_name being used to echo out the value, and be sure to target the same field_name in the module. This name can be different from the field name in the database, as the modeling and joins at times results in different names.

Next you must in the list view look at the field_name being used to echo out the value, and be sure to target the same field_name in the module. This name can be different from the field name in the database, as the modeling and joins at times results in different names.

if you have any further questions let me know.

if you have any further questions 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#775
No description provided.