<![CDATA[ [Solved] Combine extended fields (first-, lastname) in fullname - My Forums]]> https://forums.modx.com/thread/?thread=73670 <![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479430 The pre hook is executed before the fields array are saved to the database so all edits to that array in the hook should be saved.

Glad that it worked anyway.]]>
Kristoffer Oct 04, 2013, 06:15 AM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479430
<![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479376
This is working now - really appreciate you pointing me in the right direction.

Actually

$hook->setValue('fullname',$fullname);


didn't work. The debug code showed that $fullname was set correctly but setValue wasn't saving.

But your solution led me to uncover http://forums.modx.com/thread/?thread=72933&page=1 which took a different approach

$profile = $hook->getValue('register.profile');
$profile->set('fullname',$fullname);
$profile->save();


which worked.

Still be interested to know why setValue works for you though.]]>
sparkyhd Oct 03, 2013, 01:03 PM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479376
<![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479373
Is the a pre or post hook?]]>
sparkyhd Oct 03, 2013, 12:01 PM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479373
<![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479372
$firstname = $hook->getValue('firstname');
$lastname = $hook->getValue('lastname');
$fullname = $firstname . ' ' . $lastname;
$hook->setValue('fullname',$fullname);
  
return true;
]]>
Kristoffer Oct 03, 2013, 11:53 AM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479372
<![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479324
With the above, if there's validation on first and last names, and the user leaves one of them blank, how do I pre-populate value=""]]>
sparkyhd Oct 02, 2013, 04:25 PM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-479324
<![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-428869 http://tracker.modx.com/issues/7695) - personally I think adding a salutation would not be a bad idea either I will try and add to the request.

Anyway here is the (jQuery) javascript I used to combine my extended fields for first and last into full name. The event is triggered on form submit.

(NB obviously change form / field names to match yours)

Nasty hack but works for the time being...

<script type="text/javascript">
$(document).ready(function() {
	$("#reviewer_register_form").submit(function() {
		$fullname = $("#First").val() + " " + $("#Last").val();
		$("#fullname").val($fullname);
		// un-coment to debug alert("done");
		return true;
	});
 });
</script>
]]>
megasteve4 Jul 04, 2012, 06:11 PM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-428869
<![CDATA[Re: [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-409248 istvan.velsz Jan 26, 2012, 08:42 AM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-409248 <![CDATA[Re: Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-409173 sottwell Jan 25, 2012, 11:02 PM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-409173 <![CDATA[ [Solved] Combine extended fields (first-, lastname) in fullname]]> https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-409160 istvan.velsz Jan 25, 2012, 05:33 PM https://forums.modx.com/thread/73670/combine-extended-fields-first--lastname-in-fullname#dis-post-409160