Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to write to the VZ address field from a front-end entry form? #26

Closed
sgalligan opened this issue Apr 25, 2017 · 6 comments

Comments

@sgalligan
Copy link

I am looking to write to the VZ address field array from a front-end entry form, in this case saved as a part of a user's profile. For a matrix, the input field would look something like (VZ address field = member_location with the standard field values):
<input type="hidden" name="fields[member_location]" /> {% if currentUser.member_location|length %} {% for locale in currentUser.member_location %} <input type="hidden" name="fields[member_location][{{ locale.id }}][type]" value="..nameOfMatrixBlock.."> <input type="hidden" name="fields[member_location][{{ locale.id }}][enabled]" value="1"> <input type="text" name="fields[member_location][{{ locale.id }}][fields][street]" value="{{ currentUser.member_location.street }}" placeholder="Address 01" /><br /> <input type="text" name="fields[member_location][{{ locale.id }}][fields][street2]" value="{{ currentUser.member_location.street2 }}" placeholder="Address 02" /><br /> <input type="text" name="fields[member_location][{{ locale.id }}][fields][city]" value="{{ currentUser.member_location.city }}" placeholder="City" /><br /> <input type="text" name="fields[member_location][{{ locale.id }}][fields][region]" value="{{ currentUser.member_location.region }}" placeholder="State" /><br /> <input type="text" name="fields[member_location][{{ locale.id }}][fields][postalCode]" value="{{ currentUser.member_location.postalCode }}" placeholder="ZIP Code" />
...but Matrix is not writing to an array in a single field. Can you give guidance on how to access a VZ address field from a front-end form? Thank you!

@elivz
Copy link
Owner

elivz commented Apr 26, 2017

Shanan,

I am at a conference for the rest of this week, so I probably won't have time until next week to take a deeper look at this. This particular use-case isn't something I have encountered before, so I don't know the answer off the top of my head. In the mean time, you could try looking at the field names in the back-end, but I assume that is already where you got the code above.

@sgalligan
Copy link
Author

Very good, thank you. Enjoy the conference (Peers?). I have a workaround, but am still curious how to populate/edit the array in the VZ address field from a front-end entry form.

@elivz
Copy link
Owner

elivz commented May 4, 2017

Yes, I was at Peers....it was great!

I'm not sure I totally understand the setup you are trying to achieve here. Is it just an Address field, or an address inside of a Matrix? If it's in a Matrix, something like the following should work:

<div class="vzaddress-fields">
    <div class="field">
        <label for="fields-location-name">Name</label>
        <input type="text" id="fields-location-name" name="fields[matrix_field][new1][address_field][name]">
    </div>

    <div class="field">
        <label for="fields-location-street">Street Address</label>
        <input type="text" id="fields-location-street" name="fields[matrix_field][new1][address_field][street]">
    </div>

    <div class="field">
        <label for="fields-location-street2">Street Address 2</label>
        <input type="text" id="fields-location-street2" name="fields[matrix_field][new1][address_field][street2]">
    </div>

    <div class="field">
        <label for="fields-location-city">City</label>
        <input type="text" id="fields-location-city" name="fields[matrix_field][new1][address_field][city]">
    </div>

    <div class="field">
        <label for="fields-location-region">State/Province</label>
        <input type="text" id="fields-location-region" name="fields[matrix_field][new1][address_field][region]">
    </div>

    <div class="field">
        <label for="fields-location-postalCode">Postal Code</label>
        <input type="text" id="fields-location-postalCode" name="fields[matrix_field][new1][address_field][postalCode]">
    </div>

    <div class="field">
        <label for="fields-location-country">Country</label>
        <select id="fields-location-country" name="fields[matrix_field][new1][address_field][country]"> .... </select>
    </div>
</div>

Let me know if I'm misunderstanding your problem, though....

@elivz
Copy link
Owner

elivz commented Jun 15, 2017

I'm closing this. If you are still having problems with the front-end entry form, feel free to re-open.

@elivz elivz closed this as completed Jun 15, 2017
@sgalligan
Copy link
Author

sgalligan commented Jun 15, 2017 via email

@elivz
Copy link
Owner

elivz commented Jun 15, 2017

Sounds good. If & when you end up coming back to it, you will want to take a look at my sample code on Issue #27 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants