elivz / VzAddress-Craft

Address fieldtype for the Craft CMS
30 stars 13 forks source link

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

Closed sgalligan closed 7 years ago

sgalligan commented 7 years ago

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): `

{% if currentUser.member_location|length %} {% for locale in currentUser.member_location %}





` ...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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

sgalligan commented 7 years ago

Eli,

Thank you — I ended up with a different approach for the live project, but had held the issue aside with the hope of carving some time out to try out the fix with earlier prototype. I really appreciate your plugin and being able to populate it through a front-end form will be very helpful in future projects. I appreciate your attention on this!

Thank you, Shanan.


Swink | 106 East Doty Street, Suite 310 | Madison, Wisconsin 53703

On Jun 14, 2017, at 8:35 PM, Eli Van Zoeren notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/elivz/VzAddress-Craft/issues/26#issuecomment-308603745, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ9fQRQG9J9hyQAayEG1d3w8NMLnhDAks5sEIpZgaJpZM4NH-MO.

elivz commented 7 years ago

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.