<![CDATA[ Revo-Doc: Resource Fields & Output Parameters - My Forums]]> https://forums.modx.com/thread/?thread=25315 <![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129961
]]>
BobRay Jun 07, 2011, 11:28 PM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129961
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129960 Feel free to decide what was irrelevant.

So ... first of all. I conclude that output modifiers DON’T modify DB values, they just format ...

The changes were made to the Snippet calls ...
[[!UpdateProfile? &submitVar=`login-updprof-btn` ]]

[[!UpdateProfile? 
     &preHooks=`formatDobInput`
     &submitVar=`update-date-btn`
     &placeholderPrefix=`spc`
]]


I made two instances of update profile snippet call. Got this idea from something Mark H. pointed out about a posthook. (Though it was off) Figured that the prehook ran EVERYTIME I submitted even if I wasn’t editing the DOB ... so I made a normal snippet call and a special call for the DOB field.

That’s it.

That was the problem, the prehook kept running even when editing something that wasn’t needed.

Thanks guys. Hope this info helps someone else in the future.]]>
jobkingori Jun 07, 2011, 04:39 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129960
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129959 Question: Do output modifiers affecting the actual value in the DB?

I’m thinking that maybe I don’t need a posthook if the output modifier didn’t affect the value in the DB. The prehook however works well ... taking the dateformatted datepicker input and converting it to a unix timestamp (which modx uses to store the DOB). I can confirm this because a submit of the DOB value without the prehook results in an error and ok with the prehook. The chosen value is even visible in the backend.

So ... what you’ve pointed out about the posthook could be true if the output modifier actually modifies DB content ... and in that case makes sense since the prehook runs everytime I hit submit ... could be the reason why the date field goes blank.

Just a thought.

Thanks for your help btw smiley Much appreciated.]]>
jobkingori Jun 07, 2011, 03:43 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129959
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129958 markh Jun 06, 2011, 10:24 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters?page=2#dis-post-129958 <![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129957
This is my prehook ...

<?php
$dob = $hook->getValue('dob');
  $hook->setValue('dob',strtotime($dob));
  return true;
?>


I guess a posthook would work, to format the timestamp for display just like an output modifier ... however the output modifiers were made to do just that ... format the output ... the DB stores the timestamp ... hence the prehook to format my datepicker input into a timestamp, as is in the above snippet ....

UPDATE:

Uncached mobilephone number and changed the email ... the mobile number stays and the dob went blank ... same thing when i edit mobile number ... dob goes blank .... email stays.]]>
jobkingori Jun 06, 2011, 10:15 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129957
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129956
You’re missing one [ in your dob value.

And make sure *all* placeholders that deal with dynamic data are called uncached..

I suspect you will need a posthook as well (tho I’m not familiar with the profile update snippet) to reformat the date into the syntax the database is expecting... I think that’s a unix timestamp.]]>
markh Jun 06, 2011, 09:58 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129956
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129955
I have a page with many fields (in forms) and I put a submit button for each field instead of having the user fill all the fields then submit all at once. (see code below) And I have just ONE updateprofile snippet call ... because each form button is within <form> html tags so I assume that the button only updates the fields that are in that form in which the button contains.

Problem is that when I update another field its only the DOB field that is emptied ... please note that other fields are not affected JUST the dob.

I have a prehook that formatts the input from a datepicker into a timestamp ... lemme put some of the code below

My snippet call

[[!UpdateProfile?
  &preHooks=`formatDobInput`
]]


Examples of two form on the same page ... (I did this to allow the user submit one field at a time instead of the whole form)

  
  <!-- update-box: [+dob] format: d-m-Y -->
  <div class="update-profile" id="dob">
    <div class="updprof-error">[[+error.message]]</div>
    <form class="form lb_form" action="[[~[[*id]]]]" method="post">
      <input type="hidden" name="nospam:blank" value="" />
      <label for="dob">Date Of Birth (d-m-Y): <span>*</span> </label>
      <input type="text" name="dob" value="[[!+dob:date=`%a %b %e, %Y`]]" id="datepicker"/>
      <input class="btn" type="submit" name="login-updprof-btn" value="[[!%login.update_profile]]" />
    </form>
  </div>

  <!-- update-box: [+mobilephone] -->
  <div class="update-profile" id="telephone">
    <div class="updprof-error">[[+error.message]]</div>
    <form class="form lb_form" action="[[~[[*id]]]]" method="post">
      <input type="hidden" name="nospam:blank" value="" />
      <label for="mobilephone">[[!%login.mobilephone]] <span class="error">[[+error.mobilephone]]</span> </label>
      <input type="text" name="mobilephone" value="[[+mobilephone]]" />
      <input class="btn" type="submit" name="login-updprof-btn" value="[[!%login.update_profile]]" />
    </form>
  </div>

  <!-- update-box: [+email] -->
  <div class="update-profile" id="email">
    <div class="updprof-error">[[+error.message]]</div>
    <form class="form lb_form" action="[[~[[*id]]]]" method="post">
      <input type="hidden" name="nospam:blank" value="" />
      <label for="fullname">[[!%login.email]] <span class="error">[[+error.email]]</span> </label>
      <input type="text" name="email" value="[[+email]]" />
      <input class="btn" type="submit" name="login-updprof-btn" value="[[!%login.update_profile]]" />
    </form>
  </div>


So ... lets say I wanna change the email ... that works without affecting mobilephone number BUT dob goes blank. I can also change mobile phone number without affecting email. I can also set dob without affecting email or mobilephone ... so I’ve been racking my brain as to why the dob keeps getting blanked out when I update other fields.

I thought its coz I had ’!’ in my [[!+dob:date=`%a %b %e, %Y`]] call ... but if I put [[+dob:date=`%a %b %e, %Y`]] without the ! I get a blank ...

I also thought that maybe my problems were because of the prehook.

Any insight?

Been on this the whooooole day :-(]]>
jobkingori Jun 06, 2011, 09:53 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129955
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129954
Calling both the snippet and placeholder uncached is the way to go in this case.]]>
markh Jun 06, 2011, 09:19 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129954
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129953
I set the date (dob) in the backend (user manager) and called it like this (gave me a blank result on the front-end)

[[+dob:date=`%a %b %e, %Y`]]


And when I call this (with the exclamation mark)

[[!+dob:date=`%a %b %e, %Y`]]


it displays.

My snippet call is ...

[[!UpdateProfile?
  &preHooks=`formatDobInput`
]]


The format date prehook simply takes in dob input from a datepicker and converts it to a timestamp.

I also have another problem where the date disappears when I edit/submit another form on the same page ... anyone with ideas about this?]]>
jobkingori Jun 06, 2011, 09:11 AM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129953
<![CDATA[Re: Revo-Doc: Resource Fields &amp; Output Parameters]]> https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129952
The section on caching that confused you shouldn’t really be on that page at all. It doesn’t seem to have anything to do with output modifiers. I’d remove it, but it should go somewhere and I don’t know where to put it.

Note that, in theory, the output modifiers can be used with any MODx tag.]]>
BobRay Mar 03, 2011, 03:50 PM https://forums.modx.com/thread/25315/revo-doc-resource-fields-output-parameters#dis-post-129952