2

I am using Craft 2.5 (Beta) along with the fantastic SmartMap plugin. I have a user registration page that I am using the SmartMap field with like this:

twig

...
<div class="form-group has-feedback">
    <label for="address" class="sr-only">
        <span class="sr-only">This field is required.</span>
        <i class="fa fa-asterisk"></i> Street Address
    </label>
    <input type="text" id="address" name="fields[address][street1]"
    class="form-control"
    placeholder="Street Address"
    {%- if account is defined %} value="{{ account.address.street1 }}"{% endif -%}>
    {% if account is defined %}
        {{ errorList(account.getErrors('address.street1')) }}
    {% endif %}
</div>
...

I have designated the field be required in the CP, yet I'm not seeing the "Address cannot be blank" message.

I do get the error message for a default field type:

twig

<div class="form-group has-feedback">
    <label for="homePhone" class="sr-only">
        <span class="sr-only">This field is required.</span>
        <i class="fa fa-asterisk"></i> Home Phone
    </label>
    <input type="tel" id="homePhone" name="fields[homePhone]"
    class="form-control"
    placeholder="Home Phone"
    {%- if account is defined %} value="{{ account.homePhone }}"{% endif -%}>
    {% if account is defined %}
        {{ errorList(account.getErrors('homePhone')) }}
    {% endif %}
</div>

The address fields are getting re-populated if there is an error somewhere else on the form, so I know I'm at least talking to it - I just haven't been able to find the right combination

{% if account is defined %}
    {{ errorList(account.getErrors('athleteAddress.street1')) }}
    {{ errorList(account.getErrors('athleteAddress[street1]')) }}
    {{ errorList(account.getErrors('account.athleteAddress.street1')) }}
    ...
{% endif %}

EDIT

I think I may have stumbled onto something that could be related?

I have a SmartMap field in the CP with the handle of address (as shown above). On the profile tab of the user account, I have assigned the address field, and have set it to be not required.

Within my front-end registration form, I am attempting to populate the SmartMap fields. I have all of the field names matching the field names within the CP.

fields[address][street1]
fields[address][street2]

...and so on.

However, when I submit the form - which (should) be valid I am getting redirected to the form (page refreshes), the form is fully populated as if there were a validation error, and the user is not saved.

When I look at the log file, I am seeing all of the data, and it looks good so I'm not sure what the error is.

craft.log

...
'fields' => 
    array (
        'address' => 
            array (
                'street1' => '1234 My Street',
                'street2' => '123',
                'city' => 'My City',
                'state' => 'AZ',
                'zip' => '12345',
            ),
         ...

enter image description here

  • Thanks Damon! I'm not sure if there is a proper validation for the Address field yet, because it's actually a group of subfields with a slightly complex relationship. Lemme check on that one and get back to you, either here or on Slack! – Lindsey D Nov 25 '15 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.