cosmicsafari

Members
  • Content count

    31
  • Joined

  • Last visited

Community Reputation

4 Neutral

About cosmicsafari

  • Rank
    Jr. Member
  1. Hi all, A few of our clients are having issues receiving emails sent via form builder after a client submits a form. They display fine in certain clients but in Outlook especially the body content is either missing or the raw code is displayed. Does anybody have any ideas why this might be the case or any ideas about how to diagnose the issue? Not sure if this is an issue with the emails themselves or the server from which they are being sent. Just wondering if anyone else has experienced anything similar?
  2. Figured this might be useful for others. Turns out it was something to do with the version I was running. I downgraded the Form Builder plugin from 3.0.1 to 3.0.0 and the links in the administrator emails worked as expected.
  3. Hi All, Just a quick question, if a form has an upload field should there be a working link in the subsequent email which allows you to view the uploaded file? As it stands only the name and size of the file appears in the email although viewing the source it appears wrapped in anchor tags, albeit without any href attribute. I'm not sure if this is the correct result or if I have somehow managed to cause this and there should be a working link to the uploaded file.
  4. That works a treat, thanks man!
  5. Hi all, I have a module which creates numerous fields, pages etc. I would like to disable the ability to uninstall the module if any of the generated pages have children, as a mistaken uninstall could really mess up any website which is using it. Im curious about what is the best way to achieve this, currently I have some like: public function ___uninstall(){ error_log('---- UNINSTALL!! ----'); //check to see if any config pages have been added and abort uninstall if true //to avoid uninstalling and losing any work which has been done up to this point. if($this->canWeUninstall()) { //remove pages $this->deletePages($this->cPages->getPages()); //remove templates and field groups $this->deleteTemplates($this->cTemplates->getTemplates()); //remove repeaters $this->deleteRepeaters($this->cRepeaters->getRepeaters()); //delete fields $this->deleteFields($this->cFields->getFields(), $this->cRepeaters->getRepeaters()); } else { error_log('Uninstall aborted because config settings exist!'); $this->error('Whoops! Module cant be uninstalled as it appears to be in use.'); return; } } This works in the sense that it doesn't remove any of the generated content, which is good as it wont break the website. However it still shows the module as uninstalled, I can achieve what i'm looking for by replacing 'return' with 'die' but that results in a white page and looks rather rubbish so its not really a great solution. I would imagine there must be a better way to achieve this, any thoughts? Would it be possible to do this check via a hook before uninstallation and abort before we get to the point of running the uninstall() method, as I imagine that is what updates the DB to turn the module off so to speak?
  6. public function fieldGroupOverrides($name, $overrides){ foreach($overrides as $key => $field){ if (is_array($field)) { error_log('==> Override Field: ('.$key.')'); $t = wire('templates')->get($name); $fg = $t->fieldgroup; $f = $fg->getField($key, true); //All Fields, override label if(isset($field['label'])) { $f->label = $field['label']; error_log('===> Override Label Success! ('.$key.') -> ('.$field['label'].')'); } //Page Field, overide selectable pages if(isset($field['parent_of_selectable'])){ error_log('===> Override Parent of Selectable'); $parent = wire('pages')->get('name='.$field['parent_of_selectable']); $f->set('parent_id', $parent->id); error_log('===> Override Success! Parent of Selectable = ('.$field['parent_of_selectable'].')'); } wire('fields')->saveFieldgroupContext($f, $fg); } } }
  7. I tried using $f->set('parent_id', $parent->id); But I get a warning on the page This field needs to be configured before it can be used.
  8. This was what I ended up at and it seems to work ok even if it is a bit hacky. $sql = "SELECT data FROM fields WHERE id=:fieldid"; $query = wire('database')->prepare($sql); $query->bindValue(':fieldid', $f->id); $query->execute(); $data = $query->fetchAll(); $parts = json_decode($data[0][0],true); $parts['derefAsPage']='0'; $parts['collapsed'] = '0'; $parts['parent_id'] = $parent->id; $parts['labelFieldName'] = 'title'; $parts['inputfield'] = 'InputfieldSelect'; $data = json_encode($parts); $sql = "UPDATE fields SET data=:data WHERE id=:fieldid"; $query = wire('database')->prepare($sql); $query->bindValue(':data', $data); $query->bindValue(':fieldid', $f->id); $query->execute();
  9. So from messing around in the database it looks like the when you manually select a parent under the 'Selectable Pages' section and save, it adds "parent_id":X," to the 'data' cell for the field in questions record within the fields table. In context {"tags":"Page-Multi-Select","derefAsPage":0,"collapsed":0,"parent_id":1,"labelFieldName":"title","inputfield":"InputfieldSelect"} So in theory is there any reason why I can't just update the database directly without going through the API? Seems hacky but still can't find any examples of being able to do it through the API.
  10. Hi all, I am creating a page field (field of type FieldtypePage) via the API, however im still trying to find some documentation as to how I would go about setting the Selectable Pages for said field using the API. From what I have found it looks like it involves the use of, albeit this looks like a getter rather than a setter: $field->getInputfield($page) Which looks like it would make sense if I wanted to specify the selectable pages by a parent page, but what if I wanted to specify it by say a template?
  11. Hmm so I edited my code to test this an it appears that no would be the answer. It appears that you can't assign multiple as it will just overwrite the existing field group for that template.
  12. Im an idiot, turns out I had already figured this out previously somewhere else among the code for the same module! Anyway for anyone wondering I managed to retrieve them with: $fg = wire('fieldgroups')->get('field-group-name');
  13. Hi all, Just another quick question, how would I select a previously created field group so that I can add it to a template using the API? All the examples I have seen thus far are creating the field group and adding it to a template at that point, I would rather create all my field groups beforehand and then assign them to their templates in batch.
  14. Hi all, Just a quick question before I jump in and inevitably break the module I am working on. Is it possible to assign multiple field groups to a single template via the api? I am creating a whole bunch of fields, templates and pages on the fly at install and being able to assign multiple field groups to a template would be quite advantageous.
  15. Magic, thanks!