1

I have a simple Safecracker form with email, password and password confirm fields.

I tried filling up the forms with the a password less then 5 characters. When I submitted, I get this error

The password you submitted must be at least 5 characters long

in field errors.

My question is that, isn't this supposed to be an inline error? If it is not, how do access it in {field_errors}? I want it to show as an inline error near the field.

P.S. Here is my code, truncated to relevant parts.

    {exp:safecracker channel="members" class="form-horizontal" dynamic_title="[email]" error_handling="inline" include_jquery="no" register_member="yes" return="/sign-up/" safecracker_head="no"}

{if global_errors:count > 0}
    <div class="errors group tencol">
        <h3>General Errors</h3>

        <ul class="bullets">
        {global_errors}
            <li>{error}</li>
        {/global_errors}
        </ul>   
    </div>
    {/if}

    {if field_errors:count > 0}
    <div class="errors group tencol">
        <h3>Form Errors</h3>

        <ul class="bullets">
        {field_errors}
            <li>{error}</li>
        {/field_errors}
        </ul>   
    </div>
    {/if}

...

    <input type="password" name="password" value="{if post:password}{post:password}{/if}" id="password">
    {if error:password != ''}
       <span class="help-inline">{error:password}</span>
    {/if}   
1
  • Just so you know, I will get back to you on this later. Was sick over the weekend and had a full day yesterday. I will be getting caught up on support later today hopefully. Jan 8 '13 at 13:56
1

My question is that, isn't this supposed to be an inline error?

Sorry it took so long to get back with you. Short answer, no.

That's an error from the member registration class, which is a global error. Field errors, or inline errors are validated in CodeIgniter from Safecracker. One those are validated correct, the global error checks are ran. If any errors are found, they are returned.

So procedurally speaking, the field errors have already passed and now the member validation check fails. I think this is a good feature request though.

I think a work around would be to use Safecracker's validation rules to create your own minimum length which causes the field errors to fail when validating. Maybe try something like this:

rules:password="required|min_length[5]"

I have not tested this code, but if it fails in Safecracker, I could do the same routine programmatically in the extension. That would be how I solve the problem in a future update

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.