Jump to content

Custom Repeater field input title?

Recommended Posts

  • 3 months later...
  • 2 months later...
  • 5 months later...

The title function renderRepeaterLabel is hookable.  Here's a generic example, which applies to all Repeater fieldtypes:

class RepeaterTitle extends WireData implements Module {

	 * getModuleInfo is a module required by all modules to tell ProcessWire about them
	 * @return array
	public static function getModuleInfo() {

		return array(

			// The module'ss title, typically a little more descriptive than the class name
			'title' => 'Repeater Title', 

			// version number 
			'version' => 0.1, 

			// summary is brief description of what this module is
			'summary' => 'An example module used for demonstration purposes.',
			// Optional URL to more information about the module
			'href' => 'http://processwire.com',

			// singular=true: indicates that only one instance of the module is allowed.
			// This is usually what you want for modules that attach hooks. 
			'singular' => true, 

			// autoload=true: indicates the module should be started with ProcessWire.
			// This is necessary for any modules that attach runtime hooks, otherwise those
			// hooks won't get attached unless some other code calls the module on it's own.
			// Note that autoload modules are almost always also 'singular' (seen above).
			'autoload' => true


	 * Initialize the module
	 * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called
	 * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. 
	public function init() {
		$this->addHookBefore('InputfieldRepeater::renderRepeaterLabel', $this, 'repeaterLabel'); 


	public function repeaterLabel($event) {
		// Replace function
		$event->replace = true;
		// Arguments: $label, $cnt, Page $page
		$page = $event->arguments(2);
		// Show repeater page body instead
		$event->return = $page->body;


Not sure what the best way is to replace the title per specific instance of a Repeater field -- I'm still learning my way around hooks.  But I'm sure someone else knows!

  • Like 1
Link to post
Share on other sites
  • 2 years later...

Does anyone know if this possible yet?

Ideally, I would like to select the text entry of a specific field within my repeater to appear as the label for each repeater section.

Any clues as to how to do this through the GUI greatly appreciated!

Link to post
Share on other sites
32 minutes ago, kathep said:

Does anyone know if this possible yet?

Ideally, I would like to select the text entry of a specific field within my repeater to appear as the label for each repeater section.

Any clues as to how to do this through the GUI greatly appreciated!

Is this what you are looking for?

Screen Shot 2017-02-13 at 12.03.23 PM.png

Link to post
Share on other sites
  • 2 weeks later...

Hi @adrian

No. I currently use that, and it is frustrating, leading me to ask my question. 

What I want is something that will change the label on the field to the text entry of a specific field within my repeater. So when I create a new repeater, and there is a field called 'Title' within the repeater, once I enter text into the title field (for examples sake, let's say I title my repeater 'Introductory Exercise' and click 'save' on the page, the title of the repeater field in the header bar would change to 'Introductory Exercise'. 

Link to post
Share on other sites

@kathep - sorry, I think I must not be understanding properly. Would you mind posting some screenshots showing your repeater settings and an example screenshot of a completed "Introductory Exercise" title and what the repeater header bar looks like after saving?

Link to post
Share on other sites

Hi @adrian

Thanks for your quick reply. As you see, my repeater is called lesson_plan_section and has a label title of 'section'. Ideally, I would like the label text box to be able to take and process some code that says 'get text entry from the field within the repeater called "subject" and add it here'.


Here is my template 'class.php', where I have the repeater field 'lesson plan section'. As you see, each of the repeaters has a name of section #1, section #2 etc. I reguarly work with 20 sections, and the numbers are an unintuitive and awkward way to remember which section is which.


This is why I'm looking for a more user friendly solution. Unfortunately, my php skills are beginner, so I have no idea where to start in terms of hacking a solution for myself.

Link to post
Share on other sites

There is no 'repeater item labels' section on my details tab. See below - these are the only two options I see above the 'save' button at the end of the screen:


I'm using Processwire version 2.6.5 dev. Could the setting you mention only appear in a more recent version of Processwire?

Link to post
Share on other sites
3 minutes ago, kathep said:

I'm using Processwire version 2.6.5 dev. Could the setting you mention only appear in a more recent version of Processwire?

Yeah, that would be the problem. If you use repeaters a lot, then I would highly recommend updating to the latest dev version of ProcessWire. There were a lot of great new repeater features introduced in 3.0.44 (http://processwire.com/blog/posts/pw-3.0.44-repeaters/) - we are now at 3.0.52. I do think the automated header from title was available before this, but would need to track down exactly when.

2.6.5 is REALLY old now :)

  • Like 1
Link to post
Share on other sites
Just now, adrian said:

2.6.5 is REALLY old now :)

Ah ok, mystery solved. Thanks for the help Adrian!

This shows how I have been neglecting my processwire install for some time. Looking forward to enjoying all the improvements after updating!

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      So I ran into a strange error this morning when trying to publish a page. I went to publish a new page under "clients", but I get an error that says "Cannot be published until errors are corrected". I thought perhaps I had missed a required field so I checked, but none of the fields are marked as required. I then checked to see if I could just add a basic page (default basic-page.php template) under the homepage, but I get the exact same error when trying to publish. When looking at the template, I don't see any error messages being displayed above any fields.
      The odd thing I found though was if I got to "settings"  and uncheck "unpublished", I can then publish the page without errors. I did upgrade earlier today to the newest version to hopefully fix an issue I had yesterday (which it did). Has anyone run into this error before? 
      Well, after a lot of staring and pulling my hair out, I found the issues. I had installed multi-language support sometime ago (and due to the project changing, had to remove it). Apparently in my haste, I did not remove all the dependencies so it was still trying to check for the multi-language title (I am guessing) even though it actually wasnt on the page. I went through the database and removed it and can now save/publish pages without issues. 
    • By t0b1
      Hello there, and thanks for ProcessWire!
      I'm getting to know ProcessWire while doing my first project using it and I really like it so far.
      The challenge I'm facing right now is the following:
      I have a One-Pager using fullpage.js, realized as a single PW-Page containing a Repeater Field where each Repeater Item is one Section.
      Some Sections are supposed to have a little menu at the Top which references/links to different Sections of the Website, so I wanted to use a Checkbox Field "Top Menu" to decide if a Section gets a Menu and a Page Reference Field to choose the different Sections (Repeater Items) it should contain.
      I've already accomplished this by pasting the following code into /site/ready.php:
      $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'top_menu_entries') { $page = $event->arguments('page'); if($page instanceof RepeaterPage) $page = $page->getForPage(); $event->return = $page->; } });  
      The only problem that still remains is that when I select the Entry of the Repeater Item itself it doesnt save the selection, meaning after I saved it's unselected again.
      On some Sections I do want a Menu-Entry for the Section itself though (which would be styled differently and not link anywhere) for Continuity-Reasons, any ideas on how to achieve that?
    • By NehaPillai
      Hello Everyone, I was trying to update SEO meta title, description and meta keywords for my website in Process Wire CMS but it saving in the backend but it is not reflecting on my website, Please help me regarding this error. Please find below attached screen shot for your ref. TIA.

    • By AndZyk
      when you add a page you can see the page name of the page under the page title field. But when you change the page title afterwards, you have to go to the settings tab to also change the page name.
      We have many clients that change the page title afterwards but forget to change the page name, because they don't look in the settings tab or forget it.
      Is it possible to show the page name on the content tab under the page title?
      I hate to say this, but I like how WordPress handles this better:

      Or should I open an GitHub request?
      Regards, Andreas
    • By j00st
      Hi all! 
      I've been searching/browsing a bit, but can't find what I'm looking for just yet...
      Perhaps I'm searching in the wrong places, but I thought posting it here might work better/more efficient.
      I need to do the following;
      1. I have the TITLE field (the one set by ProcessWire as default).
      2. There's already a whole lot of pages of the template 'project' set up.
      3. Now I actually want to be able to add <i> and <br> tags to this title...which is possible if I turn off the specialchar encoder...
      ...but it also presents the opportunity for people to start typing, and generate the following kind of URLs:

      TITLE: This is a really long title <br> which <i>needs</i> to be split in two
      URL generated: this-is-a-really-long-title-br-which-i-needs-i-to-be-split-in-tow
      Don't want that happening. So, I thought it might be wiser to do the following.
      Next to the 'title' field, also set a 'display-title' field.
      But, preferably I'd want to generate this for all the projects already in existance...including copying their content to this new display-title field.
      Just adding the field means all the titles will need to be copied...not something I look forward to telling the editors of the site 🙂
      I saw the Hook for on-save, but that's only for the single page...and I'm not an experienced MySQL-coder/user, otherwise I guess that would've been the way to go.
      So I'm really curious to hear if you guys think there are other/better options (and what they are)
  • Create New...