Search the Community
Showing results for tags 'fieldsetpage'.
-
Hi, is there a way to activate the option Input > Visibility > Presentation > "Open when populated + Closed when blank" for a Fieldset (Page) containing some fields like text or textarea? To me it is always open, even if all fields inside are empty. Thx, Matze
-
A module to work around a few shortcomings of Fieldset and FieldsetPage fields. Not submitted to the modules directory because I'm hopeful that most if not all of this will be handled in the core eventually. https://github.com/processwire/processwire-issues/issues/1953 https://github.com/processwire/processwire-requests/issues/533 https://github.com/processwire/processwire-requests/issues/534 Fieldset Helper Adds some visibility features to fields of type FieldtypeFieldsetOpen and FieldsetPage, and adds a helper method to get the child fields of a FieldtypeFieldsetOpen field. Visibility The module adds support for the following visibility settings to FieldtypeFieldsetOpen and FieldsetPage fields: Open when populated + Closed when blank Open when populated + Closed when blank + Load only when opened (AJAX) * Open when populated + Closed when blank + Locked (not editable) Open when blank + Closed when populated "Blank" in the context of a fieldset means that all the child fields within the fieldset are blank. * The AJAX part of this option doesn't currently work for FieldsetPage. Get the child fields of a fieldset If you've ever wanted to get the child fields that are within a fieldset you will have noticed that the ProcessWire API doesn't provide a direct way of doing this. Although they appear indented in Edit Template, the child fields are actually all on the same "level" as the other fields in the template. The module adds a FieldtypeFieldsetOpen::getFieldsetFields() method that you can use to get the child fields of a fieldset for a given page. Example: $field = $fields->get('my_fieldset'); $template = $templates->get('my_template'); $fieldset_fields = $field->type->getFieldsetFields($field, $template); First argument: the fieldset Field, i.e. a Field whose type is an instance of FieldtypeFieldsetOpen (this includes FieldtypeFieldsetTabOpen). Second argument: the Template that the fieldset field is part of. Return value: a FieldsArray of child fields. If there is a nested fieldset inside the fieldset then the child fields of the nested fieldset are not included in the return value, but of course you can use the method again to get the child fields of that fieldset. https://github.com/Toutouwai/FieldsetHelper
-
Hi guys, in a website with a lot of fieldsetpages I want to show in this case accordions, only if a field (body) is populated. This is my faulty code: <?php if ($page->sectionfield_fa_membership->body) : ?> <section class="membership"> <ul uk-accordion> <li itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"> <a class="uk-accordion-title" href> <p itemprop="name">Membership</p> </a> <div class="uk-accordion-content" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"> <div itemprop="text"><?= $page->sectionfield_fa_membership->body; ?></div> </div> </li> </ul> </section> <?php endif ?> I'm getting this error: Attempt to read property "body" on null The logic is based on this code: <?php if ($page->body) { echo $page->body; } ?>
-
Hello, I have the following selector and output which works when I am logged in as an admin and as a guest as well. $pages->get("name=reports")->children()->each("report_meta_details.report_type.title") //Output //Array ( [0] => Global [1] => Global [2] => Global [3] => Global [4] => Global ) Now, The following selector returns different results for Admin and Guest: $pages->get("name=reports")->children("report_meta_details.report_type.title=Global")->each("report_meta_details.report_type.title"); //Output for Admin //Array ( [0] => Global [1] => Global [2] => Global [3] => Global [4] => Global ) //Output for Guest //Array ( ) Here, the field "report_meta_details" is a FieldsetPage, the field "report_type" is a page reference (to children of a page called report-type). Now, the first once runs for both the users; and both the users have the access to the templates, as the titles are returned correctly in the first selector. But the second one, the selector is using something that the users have access to but still does not show the results to the Guest. Any reasons why this is the case? All help is appreciated. Thanks! EDIT: I have tried the check_access=0 selector as well. But no effect.
-
Hello I've created a repeater field and have tried to add it to a FieldsetPage field. I've noticed that when inside the FieldsetPage it doesn't allow the option to clone individual repeater items. (I had originally posted this in the ProFields support forum thinking that it was isolated to repeatermatrix fields but have since seen the same result with standard repeaters, so just posting here in case anyone else has any ideas) See below image that shows both scenarios (clone button highlighted red not showing when inside fieldsetPage field) I'm sure there's probably a reason for this that I'm just not aware of, but just thought I'd check if this is intentional or if I have just found a bit of a bug? Ideally, I'd like my client to be able to have the ability to clone items and plan to have quite a lot of repeater matrix types included here so thought I'd check as it may affect how I set up my templates. Thanks in advance for any help or suggestions.
-
- fieldsetpage
- repeater
-
(and 1 more)
Tagged with:
-
In my code, I create all the fields I want included in the FieldsetPage - all good. I then create my FieldsetPage field and it appears in the Admin->Fields list - seems all good. $fields = wire('fields'); if(!$fields->get("name=widget_title")) { $field = new Field; $field->type = $modules->get("FieldtypeText"); $field->name = "widget_title"; $field->label = $this->_("Message Title"); $field->description = $this->_("Max length 64 characters."); $field->maxlength = 64; $field->stripTags = true; $field->tags = "widget"; $field->set('showCount', InputfieldText::showCountChars); $field->save(); } // Fieldset page (requires PW v3.0.74 or later) if(!$fields->get("name=fspage_widget")) { $widget = new Field; $widget->type = $modules->get("FieldtypeFieldsetPage"); $widget->name = "fspage_widget"; $widget->label = $this->_('My Widget'); $widget->tags = "widget"; $fields->save($widget); } Problem arises when I try to add fields to the FieldsetPage. While the field is created, the template and field group are not. When I try to add via code, eg $widget = $fields->get("name=fspage_widget"); $templateName = FieldtypeRepeater::templateNamePrefix . $widget->name; // Correct name but no template yet assigned to FSPage field $template = $templates->get($templateName); // results in NULL $fg = $template->fieldgroup; // Ditto due to above $titleFld = $fields->get("name=widget_title"); $fg->add($titleFld); $fg->save(); // No fieldgroup so no save it falls over with NULL template and NULL fieldgroup. I can manually add fields to the FieldsetPage via the admin field edit screen, at which point the appropriate template & fieldgroup get generated. If I try to force the creation of the template in my code when I create the field, I end up with 2 templates - repeater_fspage_widget and repeater_fspage_widget1. That leads to all kinds of madness and no fields appear in the admin edit screen for 'fspage_widget' even though the field(s) I add show they're attached to a template. It's all clearly visible in the database. I've read everything I can find including the actual code and this forum article: In this scenario, the fieldsetPage fields with their templates & fieldgroups already exist and are being migrated. Even @ryan says a the end: So, question is, after adding a new FieldsetPage field via code, how do I programmatically add its template, fieldgroup & fields?