Jump to content
horst

Using "show this field only if", no values are stored!

Recommended Posts

Hi,

I have setup a new blank site with PW 2.6.0 stable version. :)

I have created a template that has two fields, the Title and a PageTable.

The PageTable 's template contains besides the title a single Pagefield with radios plus three other fields (text or integer) that should only be shown if the right option from the Pagefield is selected. This works fine and as expected!

But the values entered into the fields do not get stored in the DB!

If I strip the showOnlyIf condition, the values get stored as expected!

With the SHowOnlyIf condition, the data isn't stored when opening the page from the PageTable-field in a modal window,

nor when selecting the page from the pagetree and open it directly for editing.  ??

Is this expected behave or do I miss something?

Edited by horst
edited subject

Share this post


Link to post
Share on other sites

Just to clarify, are the fields you're talking about hidden on saving the page or does this even happen if they are visible? Latter one can hardly be intentional.

Share this post


Link to post
Share on other sites

It is when they are visible.

Share this post


Link to post
Share on other sites

I just tested it on a new installation and it's working fine for me. 

post-874-0-21757400-1431185769_thumb.png

Share this post


Link to post
Share on other sites

Have you used the showOnlyIf conditional?

Here is a exported siteprofile of it. It is a clean and fresh install from 2.6.0 stable from today started with a blank profile: site-wrongShowonlyif.zip

Share this post


Link to post
Share on other sites

Played with your siteprofile but I couldn't spot anything. I can confirm that the issue exists. If I remove the ShowOnlyIf condition then the min-max-step values are saved properly. Putting back ShowOnlyIf and re-saving the page doesn't remove previous min-max-step values, so it seems that saving the page completely ignores these fields.

POST parameters contains all the values though.

post-3156-0-22724200-1431196395_thumb.pn

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for looking at it.

Is there a chance that I have setup something wrong? The place in pagetree where the data is saved?

Share this post


Link to post
Share on other sites

Try using this instead of "fua_fe_item_antwort.name=fua-form-slider"

fua_fe_item_antwort=1023

Seems to work here but don't ask me why :)

(trial and error)

  • Like 1

Share this post


Link to post
Share on other sites

Hey,

this works here too. But it isn't the best solution because hardcoded page-ids isn't practical. I need to export / import that at some point to another site and need to use generic properties like name. I will file an issue with this, at least I'm interested why it works with id but not with subfield.name.

But also nice to have it working for a first tests here. ^-^

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      So I ran into a very strange issue today. I have a template with a pagetable and I went to add an item to it, when I went to select an image (for an image field) the page instantly threw up an error
      "ProcessPageSearchLive: No search specified"
      The page's content also switched to the image attached. This all worked perfectly last week (local mamp box). Has anyone experienced this before, and how did you solve it?
       

    • By jploch
      Hey folks,
      I have a question regarding rendering of template files that are in a subfolder of the template folder.
      How would I for example render these PageTable items, when their template files are inside templates/blocks/:
      <div class="grid"> <?php foreach($page->grid_ext as $item): ?> <div id="pteg_<?= $item->id ?>"> <?php echo $item->render(); ?> </div> <?php endforeach; ?> </div> I tried this, but get an error:
      <?php echo $item->render(wire('config')->paths->templates . '/blocks/'); ?>  
    • By tron1000
      Hello! I use PW 3.0.98 and I have frontend editing enabled for a PageTable Field. Somehow, when I double click the field in the frontend, the iframe in wich the content is displayed is very small (see screenshot). I couldn't find out if thats some CSS conflict or another problem. Any suggestions? Thanks, Andrej
       

    • By Noel Boss
      I use a PageTable field to make edits to children of pages more intuitive…
      To register the hooks, insert the following Snippet inside your init function in your module (or add it to your init.php file):
      /** * Initialize the module. * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. */ public function init() { // Prefill pageTable field $this->wire()->addHookBefore('InputfieldPageTable::render', $this, 'addChildrenToPageTableFieldsHook'); $this->wire()->addHookBefore('InputfieldPageTableAjax::checkAjax', $this, 'addChildrenToPageTableFieldsHook'); } Then, add this hook method:
      /** * Fill pagetable fields with children before editing…. * * @param HookEvent $event */ public function addChildrenToPageTableFieldsHook(HookEvent $event) { $field = $event->object; // on ajax, the first hook has no fieldname if (!$field->name) { return; } // get the edited backend page $editID = $this->wire('input')->get->int('id'); if (!$editID && $this->wire('process') instanceof WirePageEditor) { $editID = $this->wire('process')->getPage()->id; } $page = wire('pages')->get($editID); // disable output formating – without this, the ajax request will not populate the field $page->of(false); // you could also insert a check to only do this with sepcific field names… // $page->set($field->name, $page->children('template=DesiredTemplate')); // just specific templates $page->set($field->name, $page->children); } Now whenever there is a page-table field on your page, it gets populated with the children
    • By pppws
      Hey there,
      i've set up a page wich uses pageTable and it works like a charm.
      for my home page i get several pages. they are sperated in two types:
      a) page has the module 'featured_img'
      b) page doesn't have the 'featured_img'
       
      my pageTable field is called add_modules. so i was wondering if something like 
      <?php foreach ($featured as $child): ?> <?php if ($child->add_modules->module_featuredimg): ?> // show image <?php else: ?> // show text <?php endif; ?> <?php endforeach; ?> is possible?
       
      thanks for your input!
×
×
  • Create New...