pogidude Posted June 14, 2013 Share Posted June 14, 2013 I'm updating this module. and I'm trying to add a field/form like in the screenshot. Where the admin can select a page that users will be able to add to (left side) and what templates they can add (right side). This should work like a repeater field. I can build the first part. I'm not very sure how to build the second part since the second field, in the repeater, is a select field of templates. Oh yeah, I'm not even sure how to programmatically build a repeater field. Here is my code: public function ___install() { .... //add role_add_children_pages $field = new Field(); $field->name = 'role_add_children_pages'; $field->label = 'Pages users with this role may add to'; $field->labelFieldName = 'path'; $field->type = wire('modules')->get('FieldtypeRepeater'); //now what?? //$field->type = $field->description = 'In order to add to child pages, this role must have page-edit permission or the user must also have another role with page-edit permission.'; } or if there's a module that uses repeater fields in a similar way I can take a look at that. Link to comment Share on other sites More sharing options...
kongondo Posted June 14, 2013 Share Posted June 14, 2013 Oh yeah, I'm not even sure how to programmatically build a repeater field. Perhaps this post will be helpful? http://processwire.com/talk/topic/958-repeatable-fields/?p=8432 And this too: http://processwire.com/api/fieldtypes/repeaters/ 1 Link to comment Share on other sites More sharing options...
pogidude Posted June 15, 2013 Author Share Posted June 15, 2013 Thank you kongondo.. the links you posted will help with the repeater stuff.. Now if I can just create a page template select box. Link to comment Share on other sites More sharing options...
kongondo Posted June 15, 2013 Share Posted June 15, 2013 I only no how to do that using API and the $template API variable echo "<select>"; foreach ($templates as $template) { echo "<option value=''>{$template->name}</option>"; } echo "</select>"; Link to comment Share on other sites More sharing options...
ryan Posted June 16, 2013 Share Posted June 16, 2013 I'm pretty sure that a Repeater can't be used for Inputfield forms outside of ProcessPageEdit. It's sufficiently complex enough, and tied into its storage engine (pages) that it can't be used for other forms. As a result, if you need something similar, you might have to bundle your own input type into an InputfieldMarkup or something. Link to comment Share on other sites More sharing options...
pogidude Posted June 16, 2013 Author Share Posted June 16, 2013 Thanks ryan. Anyway, let's forget about the repeater field for now. My real question is, how do I create a select box or something similar that allows a user to select page templates.. as in my original question Link to comment Share on other sites More sharing options...
pogidude Posted June 17, 2013 Author Share Posted June 17, 2013 the ultimate goal is to restrict a user to create pages only on specific branches and what types of pages they can create on that branch. Link to comment Share on other sites More sharing options...
ryan Posted June 18, 2013 Share Posted June 18, 2013 Thanks ryan. Anyway, let's forget about the repeater field for now. My real question is, how do I create a select box or something similar that allows a user to select page templates.. as in my original question I'll use an example of the Checkboxes inputfield, but it could also InputfieldAsmSelect or InputfieldSelectMultiple, etc. This is in the context of a ConfigurableModule's getModuleConfigInputfields() method, though it would be the same elsewhere. public static function getModuleConfigInputfields(array $data) { $form = new InputfieldWrapper(); if(!isset($data['templateIDs'])) $data['templateIDs'] = array(); $f = wire('modules')->get('InputfieldCheckboxes'); $f->attr('name', 'templateIDs'); foreach(wire('templates') as $template) { $f->addOption($template->id, $template->name); } $f->attr('value', $data['templateIDs']); $form->add($f); return $form; } Link to comment Share on other sites More sharing options...
pogidude Posted June 19, 2013 Author Share Posted June 19, 2013 Is it possible to create a Templates select box field in ProcessPageEdit? Link to comment Share on other sites More sharing options...
ryan Posted June 20, 2013 Share Posted June 20, 2013 Is it possible to create a Templates select box field in ProcessPageEdit? That's essentially what I posted above, though in a different context (module config rather than ProcessPageEdit). If you wanted one in ProcessPageEdit, you'd probably want to create a new Fieldtype for it. Actually, just checked and it looks like Hani already has. 1 Link to comment Share on other sites More sharing options...
pogidude Posted June 20, 2013 Author Share Posted June 20, 2013 That's essentially what I posted above, though in a different context (module config rather than ProcessPageEdit). If you wanted one in ProcessPageEdit, you'd probably want to create a new Fieldtype for it. Actually, just checked and it looks like Hani already has. hmmmm.. now I'm getting it.. thanks! how do I check for module dependencies in my module? I'd like to notify user to install Hani's module if it's not yet installed. Link to comment Share on other sites More sharing options...
ryan Posted June 22, 2013 Share Posted June 22, 2013 Here's more information about how to use and implement module dependencies: http://processwire.com/talk/topic/778-module-dependencies/ Link to comment Share on other sites More sharing options...
pogidude Posted June 22, 2013 Author Share Posted June 22, 2013 just thought to tell you Ryan that everything *clicked* today. basically, what you were saying was, "create a Template Select input field module and use that for my other module" right? of course I don't have to do that anymore with Hani's module + dependencies but this definitely was lightbulb moment for me thanks 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