Ole Posted August 14, 2014 Share Posted August 14, 2014 I need a select field, that is editable (add, erase, edit options) for the admin and different user-roles through the backend.Is there another way than:1) Choose a Page-Reference Field and add for every Option a new Page.2) Use the Form Builder Module and rebuild the "whole" (6 fields...) Contact Form.Or is it possible, to make one field editable for a specific user-role, without providing admin access? Link to comment Share on other sites More sharing options...
adrian Posted August 14, 2014 Share Posted August 14, 2014 I have done something like this for a form where the user can choose from a bunch of options, but if they choose "other", they can add an option to a text field. When the form is submitted, the value from this field is added to the page field (and selected for their submission) so that it will be available for the next user filling out the form. Sounds like you need another level of control though if you want a front-end user to be able to edit the contents of the page field - is that the scenario you are after? Link to comment Share on other sites More sharing options...
Ole Posted August 14, 2014 Author Share Posted August 14, 2014 No, thats not my scenario. My case is simpler than your solution.On my site, the front-end user (Role: guest) won't have rights, to change any content. It is just possible to choose between the various options.The "editor" (my own Backend-Role) is allowed to work on this Option-Field and create/edit the different options. But he has no Admin Access to all Fields, Templates etc.I don't want provide ultimate admin rights to the Editor. It would be nice to have a solution, where he can access and edit this field only, but no other fields or templates. Link to comment Share on other sites More sharing options...
adrian Posted August 14, 2014 Share Posted August 14, 2014 Oh I see - if I understand correctly I think module might help you out: http://modules.processwire.com/modules/page-edit-field-permission/ Link to comment Share on other sites More sharing options...
Ole Posted August 15, 2014 Author Share Posted August 15, 2014 Unfortunately this module doesn't help me.I use Ryans FormTemplateProcessor module (https://github.com/ryancramerdesign/FormTemplateProcessor). The Select Field, which I need editable, is just implemented in a template. This template contains all contact form-fields, has no own template file and is rendered in another template.That means, the non-Admin Backend User would need access to the Setup > Field > *SpecialSelectField* Configuration. Link to comment Share on other sites More sharing options...
Soma Posted August 15, 2014 Share Posted August 15, 2014 Just use a page field and create pages for the options. Those pages can be edited or added and then build the select. Simple and effective. Link to comment Share on other sites More sharing options...
Ole Posted August 15, 2014 Author Share Posted August 15, 2014 Ok. And everything comes down to pages... I'd already this option in my mind, but want to know, if there is another solution with PW, which I haven't recognized yet. Link to comment Share on other sites More sharing options...
Soma Posted August 15, 2014 Share Posted August 15, 2014 You could take a textarea field, and take that to enter option one per line and use that to populate the select. 1 Link to comment Share on other sites More sharing options...
Ole Posted August 19, 2014 Author Share Posted August 19, 2014 I like the Textarea Solution a bit more than the Page Option.But I'm not skilled enough with the PW API (or just not smart), to add the Textarea field to the Contact-Page Frontend-Output? My naming: contact (Template)Connected to the Contact-PageEditor User has no direct access to the template (field configuration etc)Has a PHP-template-file Contact (Page)Editable by the Editor UserShould contain the select field options contactform (Template)All the in the Page available Input Fields are selected in this template.Has no own PHP-template-file.Not editable by the Editor User This is my code of the contact-Template (Frontend-Output): $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get('contactform'); // required [...] echo $form->render(); // draw form or process submitted form Is there an easy way to get the editable Textarea Field from the Contact-Page into the contactform-Template or into the generating Process inside the contact-Template. Link to comment Share on other sites More sharing options...
kixe Posted September 7, 2014 Share Posted September 7, 2014 Hi Ole,create new permission called 'field-admin'add this permission to the role you named 'Editor User'The Editor will get the Tab 'Setup' with Submenu 'Fields'Now he can add/edit field settings. Unfortunately for all fields like admin If you want to limit the list to only a few field, then you have to write your first module which hooks in 'ProcessField.module'. Its more for advanced PW Users ... but just in case:- take the following module (tested in PW 2.4.18) put it in site/modules Folder- install module- create new permission called 'field-editor'- add this permission to the role you named 'Editor User' or what ever- create a new page 'MyFieldeditor' under admin/setup/ with template admin.- select Process: ProcessFieldEditor- now the 'Editor User' will find a Setup Tab with Submenu 'MyFieldeditor'- only the fields you have set in the Module will be visible in the list <?php /** * ProcessWire Module * * * first approach by kixe * */ class ProcessFieldEditor extends ProcessField implements ConfigurableModule { public static function getModuleInfo() { return array( 'title' => __('Fields', __FILE__), 'summary' => __('Edit settings of individual fields by Role field-editor', __FILE__), 'version' => 100, 'permission' => 'field-editor', // add this permission if you want this Process available for roles other than Superuser 'icon' => 'cube', ); } /** * settings * IDs of fields to show in the table * better to make a configurable module */ protected $data = array(164,123,111); protected function ___getCustomListTable($fields) { $table = $this->modules->get("MarkupAdminDataTable"); $headerRow = array( $this->_x('Name', 'list thead'), $this->_x('Label', 'list thead'), $this->_x('Type', 'list thead'), $this->_x('Templates', 'list thead quantity') ); $table->headerRow($headerRow); $table->setEncodeEntities(false); $numRows = 0; foreach($fields as $field) { if (!in_array($field->id,$this->data)) continue; $row = $this->getListTableRow($field); if(!empty($row)) { $table->row($row); $numRows++; } } if(!$numRows) $table->row(array($this->_("No fields matched your filter"))); return $table; } /** * Render a list of fields set in modules configuration * */ public function ___execute() { $out .= $this->getCustomListTable($this->fields)->render(); $out .= "\n</div><!--/#ProcessFieldList-->"; return $out; } } I put it together quickly. So no guarantee. Just a first approach to show one of millions possibilities to customize Processwire very easy. Thats why it is genious and I like it so much. Link to comment Share on other sites More sharing options...
Ole Posted September 8, 2014 Author Share Posted September 8, 2014 This looks pretty sick! I'd thought, I'm not bad with PW. But there is so much more to explore... I think I have to take a deeper look on the whole backend programming, with hooks and all the other parts.Your stuff seems to be a a nice start for that.Thanks for your idea! 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