renobird Posted July 24, 2014 Posted July 24, 2014 hello all, In a process module I have a form, and I can't figure out how to set all the options to "checked" for a checkboxes field. See the "semester" and "year" sections of the code below. // Form $form = $this->modules->get("InputfieldForm"); $form->id = 'filters'; $form->method = 'get'; $form->action = './'; // Fieldset $fieldset = $this->modules->get("InputfieldFieldset"); $fieldset->label = "Filters"; $fieldset->icon = "fa-filter"; $fieldset->attr("", "filters"); $fieldset->collapsed = true; // Course Search $field = $this->modules->get("InputfieldText"); $field->label = "Search by Course Number or Title"; $field->description = "Start typing a course number or title to filter the list below."; $field->attr("name+id", "course_search"); $field->columnWidth = 60; $fieldset->add($field); // Semester $field = wire('fields')->get('semester')->getInputfield(wire('page')); $field->attr("name+id", "semester"); $field->columnWidth = 20; $fieldset->append($field); // Year $field = wire('fields')->get('syllabi_year')->getInputfield(wire('page')); $field->attr("name+id", "year"); $field->columnWidth = 20; $fieldset->append($field); $form->add($fieldset); The "semester" and "year" fields are page fields output as checkboxes, and when I render the form in my admin page, the fields and all the available options show correctly (see below). What I'm after is a way to render the form and have all the checkboxes show as checked. Currently renders like this What I need Any help would be appreciated.
arjen Posted July 24, 2014 Posted July 24, 2014 How about: $field->attr('autocheck', 1); or: $field->autocheck = 1; Or is this for single checkbox only?
Soma Posted July 24, 2014 Posted July 24, 2014 what is the inputfield selctable pages defined with? $field->attr("value", $field->getSelectablePages(new NullPage)); should work? 7
renobird Posted July 24, 2014 Author Posted July 24, 2014 @arjen I had hoped it was that easy too — perhaps for a single checkbox field. No luck for this. @Soma Bingo! $field->attr("value", $field->getSelectablePages($page)); Thank you good sir! That was it. 1
adrian Posted July 24, 2014 Posted July 24, 2014 EDIT: Looking at all those new posts above (should have checked before I sent my post), it looks like I was not on the same page
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