Federico
Members-
Posts
106 -
Joined
-
Last visited
Everything posted by Federico
-
How to populate a custom module with fields from template
Federico posted a topic in General Support
Dear Community, I would like to create a module in the admin, that echoes all fields existing in a template (like to mimic a page with same template) . So far so simple, but this gives me an error.. ... public function ___execute(){ // Build form $form = $this->modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'$page->name'); // Build fieldset $fieldset = $this->modules->get('InputfieldFieldset'); $fieldset->label = 'Personal Data'; // Read out template fields and append them to the fieldset $taxonomy = $this->templates->get("taxonomy"); foreach ($taxonomy->fields as $field) { $field = $field->getInputfield($page); // THIS GIVES ERROR $fieldset->append($field); // THEREFORE ALSO THIS GIVES ERROR } $form->append($fieldset); // Submit $submit = $this->modules->get("InputfieldSubmit"); $submit->attr("value","Anmelden"); $submit->attr("id+name","submit"); $form->append($submit); return $form->render(); } Something wrong inside the foreach.... -
Front-end custom form: how to retrieve an inputfield css class
Federico replied to Federico's topic in General Support
@Robin S thanks, well I've been two days exploring all possible scenarios, then a simple $type = $inputfield->inputfield; made my day aka that's exactly what I was looking for! many thanks -
Front-end custom form: how to retrieve an inputfield css class
Federico replied to Federico's topic in General Support
Yes @dragan, correct i would like to recreate existing admin form in the frontend, by implement a logic with full control over CSS styles. If these methods are not available in the frontend, how do you suggest considering a modules->get with granular CSS control over input fields? ps lot of threads over this thing, however before going with form builder, I would like to better understand what could be achieved by custom logic thanks a lot -
Front-end custom form: how to retrieve an inputfield css class
Federico replied to Federico's topic in General Support
-
Front-end custom form: how to retrieve an inputfield css class
Federico replied to Federico's topic in General Support
Neither this check doesn't outputs anything... if ($inputfield == 'InputfieldPage') { if($inputfield->hasClass('InputfieldPageListSelectMultiple', 'contentClass')) { echo "Yes! I am page reference field with the InputfieldPageListSelectMultiple field type selected !!!"; } ...other code } I don't know what's left to do... -
Front-end custom form: how to retrieve an inputfield css class
Federico replied to Federico's topic in General Support
I've tried almost all options available in there, but no luck so far - maybe I am doing it wrong Just to make sure, is this the correct way to retrieve options within the foreach? -
Hello, I am building a custom front-end form to create or populate pages, however I need to retrieve some css rules from existing fields in a page, in order to add them to front-end fields and style them accordingly. In particular I have to retrieve the css class that defines which input field type is a pageReferenceField - this case is "select", and the css is <div class="InputfieldSelect">....</div> Whereas for the same pageReferenceField with an input type asm select multi, its css class is as follow: <div class="InputfieldPageListSelectMultiple">.....</div> this is part of the code $inputfields = $pages->get(1041)->getInputfields(); // get the form inputfields from a specific page foreach($inputfields as $inputfield) { // loop through them if(in_array($inputfield->name, $ignorefields)) continue; echo $inputfield->get(class); // NEED TO RETRIEVE THE CSS CLASS THAT DEFINES THE TYPE OF PAGE REFERENCE INPUTFIELD (THIS CASE IS SELECT, BUT COULD BE ASM, RADIO, ETC) .. other code... } Do you know how to retrieve this specific css class? Thank you very much
-
How to add only one button to custom module that uses lister
Federico replied to Federico's topic in General Support
Awesome, I didn't try this ajax conditional and the call made twice was the cause. I've changed only this to the above, to wrap all into one sigle $out $out .= $pl->execute(); // .= instead of simply = thank you very much -
this depends on the number of users inputing working hours per day, as they could be like 100 every days, resulting in a potential scenario like 100(users)x24(max hours) = 2400 repeaters items every day (so a single page could potentially hosts like 2400 repeaters). Does this sound doable? I've tried it, very powerful, but first I have to find the most appropriate logic to store working hours. I'll definitely give it a another try with the above logic, if no better solution will arise
-
Thank you for the inputs Francis My situation is very similar to what you have narrowed down, though my major doubt is still how to store such ever increasing amount of data in database. In particular, I am thinking to store user working hours as follow: under page "timesheet", the custom module will generates children pages corresponding to each inputed days (even if only one single user will input a working hour for certain day, the module will generates a children page named with the current date) - so after one working week I will expect to get a structure similar to this: Home - Projects -- Project 01 -- Project 02 .... - Timesheet (all children pages contain repeaters to store user working hours) -- ts-2017-12-02 -- ts-2017-12-03 -- ts-2017-12-04 -- ts-2017-12-05 -- ts-2017-12-06 - Admin -- Users --- user 01 --- user 02 .... Each timesheet children page contains a repeater to include every working hours for each users. Doing so I will limit the usage of repeaters within the same page, as this is the only parameters I can assume will stay under reasonable number (it depends only on how many users will be inputing working hours, but they can normally need just 1 repeater/user) Do you think this is a valid approach? (referring to the Timesheet children pages corresponding to each working days, where each children pages have repeater inside them to store the user working hours) Alternative to this approach? much appreciated
-
Hi there, I would love to hear your opinion regarding the possibility to store and manage users timesheets in relation to some projects, all within PW system. In essence, I need to find a working solution to let some users under this page tree: - Admin -> Access -> Users to fill a timesheet (under custom admin module), for every working day. The info I need to store in database is composed as follow: 1 - the user selects the day by picking it from a daytime inputfield -> Date 2 - then the user select an existing page located elsewhere in the system (called projects) -> Project name 3 - user adds number of working hours dedicated to that project, repeating the whole set if within the same day the projects where more than one -> Nr. of hours Each PW users should be able to see only their inserted values (all days stacked in a table manner), not what other users placed from their own. So depending on user login, one might see different rows in the timesheet table. I am thinking a sort of repeater list with sort of user permissions - all within the custom module form - but since repeaters are not suitable for unknown large dataset, I am still looking for better paths. What do you suggest about storing such potential infinite scalable data? Thank you very much fm
-
How to add only one button to custom module that uses lister
Federico replied to Federico's topic in General Support
Can you please suggest how to disable the AddNew page button in this case? like this? $pl->addNew = false; // ??? just an assumption, as this doesn't exists in lister options -
Hello everyone, I am using a custom module with lister, which works just fine. The only thing that troubles me is how to display only one button at the top, instead of many duplicates that the lister module generates. here couple of snapshots to show it This is the button (green one on top right) on the header, which is the expected position. So the header looks perfect, whereas in the footer the module generates automatically two additional buttons (not wanted) the code to generates the lister and the button is all in ___execute() function. Here's the code $btnAddNew = $this->modules->get("InputfieldButton"); $btnAddNew->showInHeader(); $btnAddNew->href = "{$this->wire('config')->urls->admin}page/add/?parent_id=1101"; $btnAddNew->icon = 'plus-circle'; $btnAddNew->value = "Create new project code"; $btnAddNew->aclass = "classeAnchor"; $btnAddNew->addClass = "pw-modal"; $btnAddNew->id = "Test"; $pl = $this->modules->get("ProcessPageLister"); return $pl->execute() . $btnAddNew->render(); I've also tried this lister option: $pl->toggles = array('collapseFilters', 'noButtons'); // setting the deafult filter as collapsed, and no additional buttons but no luck for me. Then also I'm experiencing problem with the modal window for the button, as when I click the button the modal appear and abruptly redirects to add page section of PW, outside of the modal. But this is just a different issue.. Any help would be much appreciated
-
Hi all, what is the best way to get a custom field value, currently viewing in a single user page (admin side) and within the ready.php? I tried the following, without success $fieldValue = $page->customFieldName; // tentative 01 - fails $fieldValue = $this->customFieldName; // tentative 02 - fails $fieldValue = $this->page->customFieldName; // tentative 03 - fails note that the custom field is a simple text field I need it to auto populate another custom field that follows the one above thanks!
-
works like charm! thanks!
-
Hi all, I am having trouble on setting a fieldtype visibility from API, I need to set it as locked on a page save. here is the code from the module, which is called on init() $this->addHookBefore("Inputfield::render", $this, "renderFieldFolder"); Now, everything's ok except the locked feature, I can collapse or open the field from API but no way to lock it public function renderFieldFolder(HookEvent $event) { $field = $event->object; if($field->name == 'proj_code_folder') { $field->collapsed = Inputfield::collapsedNoLocked; } } Any clue?
-
@Robin S after additional tests, I've found that the "007" release works as expected for fieldset visibility only outside individual templates (fields visibility overwrite). correct?
-
How to populate an integer fieldtype via autoload module
Federico replied to Federico's topic in General Support
your math is correct @adrian a simple text field type does the job. Thank you all -
Thanks @Robin S, awesome support! For whatever reason, my fieldset did not changed its behaviour from 0.0.6 to 0.0.7, I still cannot control it via custom selectors after page save. I reverted back to the combo presentation "closed" and checkbox fieldtype "yourcheckboxfieldtypeName" as "not checked", as this is still a working solution for me. I mean, when the checkbox is checked and the page is saved, than the fieldset is showed. If not checked, the fieldset is hidden via css
-
How to populate an integer fieldtype via autoload module
Federico replied to Federico's topic in General Support
Thank you all, It was my mistake, as the module itself was not properly loaded. The code above actually...works! sorry for that. Good to know that in PHP methods are not case sensitive! @Robin S yes I know and tried the module, what I do not like of that is the fact that creates additional db table to store progressive numbering, but I can't really say anything about what is the best approach in terms of efficiency and data storage. Btw, do you know how to store padded numerical values within the integer fieldtype? like this "0013" - I guess it requires changes to the default fieldtype behaviour in order to achieve this -
Hello PW community, I know this is a discussed topic in some other posts, but none of them seem to work when I try to implement found suggestions. Sorry for duplicate it. Goal: I would like to populate an integer fieldtype (called proj_code_sint) before a page is rendered in the admin, all from an autoload module. here's the sample code, which for unknown reason it doesn't do anything... <?php class moduleTitle extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return string * */ public static function getModuleInfo() { return array( 'title' => 'moduleTitle', 'version' => 001, 'summary' => 'Autopopulate integer fieldtype with incremental number', 'author' => 'mf', //'singular' => true, 'autoload' => "template=admin", ); } public function init() { $this->addHooKBefore("Inputfield::render", $this, "renderField"); } public function renderField(HookEvent $event) { $field = $event->object; // here custom logic if($field->name == "proj_code_sint") { $field->set('value', '123'); // example } } } Can you please suggest what I am missing here? maybe to save() the page at the end? thank you very much
-
That's true, as you also stated in the github issue. My aim was focused on finding a temporary solution to let custom php selectors hide/show the fieldset group on a page save. By apply custom php selector with presentation "open", these selectors will not work simply because the fieldset group will be not rendered in the html code (at least in may case). Oppositely, by considering fielsdet presentation as "closed", your php-based filters seem working as the fieldset is rendered in the html code (thus managed by css on a page load). <div class="InputfieldContent">....</div> is the part of the fieldset that will be hidden/shown based on your php selector ( in my case I display the whole fieldset with a checkbox, after a page save). Bottom line: I totally agree with you statement below, that secures that no one can manipulate the hidden fieldset
-
Thanks @Robin S, I see the issue of manipulating the display:none via user dev console, therefore your approach seems more suitable for this case. As of the core feature "Show this field only if", although it works properly, it doesn't requires a page to be saved (immediate show/hide via js) - thus not suitable in case like mine where you need the user to save page before showing the fieldset. However, I've tested the option/workaround reported above, and so far so good
-
ok after many tentatives, I've found what could be the thing: The fieldset group (I bet also the fieldsetTab, though not tested), when not showed - with custom filter - is actually removed from the html code. This means that the fieldtab visibility selectors will not simply add a css "display:none" but actually remove it completely, leaving all the grouped fields as single <li> list objects. To overcome this, you should consider a presentation option in visibility as closed (thus not open..), before proceeding with any selector or php code. Hope it helps, in case this was not yet discussed here thanks! fm
-
Hello, Thank you @Robin S for this awesome module, really. Just a silly doubt, maybe I miss something, but is it only me having trouble to manage visibility for a fieldset type with nested fields (not fieldsetTab)? I mean, within a certain template, and under its tab "Input - Visibility - show only if custom PHP returns true", I would like to get the fieldset group visibile only if a checkbox field (called proj_code_valid) is checked and the page is saved. So this is my condition if($page->proj_code_valid == 1) return true; I've tried many alternatives, but none of them were successful.. Note: I've updated the module to its latest version 0.0.6 (my PW version is 3.0.62).