Gazley Posted March 22, 2016 Share Posted March 22, 2016 Hi there, This question has possibly been asked and answered but I couldn't seem to find a related topic. I have a Template (Template1) that contains a number of fields, one of which is a Page field. I have an Admin Access page based on this template and data is entered into the page based on Template1. When the Page field is set on this page, it obviously relates to a different page/template (Template2) that likewise contains its own data. This is the real gist of the question: After I select a page in the Page field on Template1, how can I have displayed, a piece of "Read Only" data from Template2, adjacent to the Page field in Template1. It's really like I want to create a "custom" read-only field in the template that responds to the settings of the other fields in the template, in this case, a Page field. Obviously, this would be trivial if I was generating output markup based on Template1. However, Template1 is behind an Admin page that is used for data-entry and I want to show data from the page referenced by the Page field for "information" purposes, solely to help the person who is inputting data. The second part of this question is that the Page field in Template1 is actually in a Repeater Matrix that is a specified field in Template1. I'm sure that the technique would be similar irrespective of whether the Page field is directly in a Template or inside a repeater in a Template. Hope this makes sense! I look forward to any suggestions you may have Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 22, 2016 Share Posted March 22, 2016 You can hook ProcessPageEdit::buildForm to dynamically add custom fields (e.g. InputfieldMarkup) to page edit forms based. Is that what you're looking for? 2 Link to comment Share on other sites More sharing options...
kongondo Posted March 22, 2016 Share Posted March 22, 2016 (edited) I seem to recall something similar but can't find it now. You could consider using the module RuntimeMarkup using some custom JS to monitor select changes or if you don't want it to detect live changes just to display the output you want on save. Your PHP code could even reside in a file that you could access using WireRender(). It (the output) wouldn't really be 'adjacent' to your Page Field though Edited March 22, 2016 by kongondo 2 Link to comment Share on other sites More sharing options...
Gazley Posted March 22, 2016 Author Share Posted March 22, 2016 @LostKobrakai - that sounds about right. I've used hooks in the past (infrequently) but I've no clue how to create a custom field. Do you have any suggestions as to where I can acquire this knowledge? Any tutorials or sample code that you're aware of? Many thanks! @kongondo - thanks for the pointers. The ProcessPageEdit::buildForm suggested by @LostKobrakai sounds like it will work but I'll definitely look at your suggestions too. Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 22, 2016 Share Posted March 22, 2016 kongondo's module is basically what I suggested in module form, so I'd suggest trying that at first. Link to comment Share on other sites More sharing options...
Gazley Posted March 22, 2016 Author Share Posted March 22, 2016 @LostKobrakai, ah OK, so @kongondo bundled the solution in his module - cool! Thanks for the help Link to comment Share on other sites More sharing options...
kongondo Posted March 22, 2016 Share Posted March 22, 2016 (edited) It could be as simple as having code like this in your RuntimeMarkup field settings for template 1 //pseudo code $out = 'No value entered'; if($page->name_of_single_page_field->title == 'whatever') { $out = $pages->get('/some-page/, template=template-2')->title; } return $out; If you have further questions let's take it at the module's support forum Edited March 22, 2016 by kongondo 1 Link to comment Share on other sites More sharing options...
Gazley Posted March 22, 2016 Author Share Posted March 22, 2016 Thanks @kongondo! Glad to know that others have this requirement to the extent that you built a module for it Link to comment Share on other sites More sharing options...
Macrura Posted March 26, 2016 Share Posted March 26, 2016 replying to the OP - use a data- attribute on the select using jQuery you read that data attribute for the selected item and then show it... see more here: https://processwire.com/talk/topic/419-extending-inputfields/?p=76861 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now