Forums

How do I join first & last name fields to create name field?

cyberdude 03 Dec, 2010
I've just started using CF and it's amazing but being newbie to J! and CF I'm a little stuck.

I have created a form which asks specifically for First Name and Last Name. I also what this form to link to the J! registration, via the plugin, which only uses a single name field. How can I combine the fist and last name fields to form a single name field to be used in the J! registration form plugin?

Many thanks.
GreyHead 03 Dec, 2010
Hi cyberdude,

Please search here on 'first_name', the question has been answered several times.

Bob
cyberdude 04 Dec, 2010
Thanks. I eventually found it on page 13 of the search results. I did do a search before asking but gave up after page 6 or 7 of the results.

For anyone else interested the answer is here.
GreyHead 04 Dec, 2010
Hi cyberdude,

Sorry it was so far down :-(

The ChronoSearch form from the Tutorials menu above often gives better results that the forum search here.

Bob
cyberdude 04 Dec, 2010
No worries. I'll bare in mind to use the other search next time.

The code is not working properly. It's only inserting the first name into the name field for some reason. This is the code I have.

<input value="name" id="hidden_9" name="name" type="hidden" />
I also tried the code as posted in the link above but it didn't work either.
    <input type="hidden" name="name" value="" />


This is what's added to the OnSubmit before part. FirstName and LastName are the fields in my table.
<?php
    $first_name = JRequest::getVar('FirstName', '', 'post');
    $last_name = JRequest::getVar('LastName', '', 'post');
    $name = $first_name." ".$last_name;
    JRequest::setVar('name', $name, 'post');
?>

I can't see anything obvious but then I'm not really familiar with php.
cyberdude 04 Dec, 2010
OK, I solved it.

Was a silly mistake 😶 . I didn't have the correct field name for 'name' in the Joomla Registration plugin. Once I fixed that the code works.

I simplified it to
<?php
JRequest::setVar('name', JRequest::getVar("FirstName")." ".JRequest::getVar("LastName"));
JRequest::setVar('lead_name', JRequest::getVar("FirstName")." ".JRequest::getVar("LastName"));
?>
and removed the hidden fields as they are not required apparently.

The second JRequest command does the same thing for another table used in our lead capture form.
This topic is locked and no more replies can be posted.