ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

SafeCracker and Login form on one page

August 20, 2012 10:17am

Subscribe [3]
  • #1 / Aug 20, 2012 10:17am

    4ksner

    12 posts

    Hi!
    I`m trying to use SafeCracker and Login form on one page, but if I`m trying login on site I get error that Title field is empty.

    That my login form:

    {if logged_in}
                    
                        {exp:member:custom_profile_data}
                        
                        Вы вошли как: <b>{screen_name}</b> / <a href="http://{path=LOGOUT}">Выйти</a>
                        
    
                        <a href="http://{path=member/profile}">Ваш профиль</a> / <a href="http://{path=member/memberlist}">Все пользователи</a> 
                        
                        {/exp:member:custom_profile_data}
                    
                    {/if}
                    
                    {if logged_out}
                    
                        {exp:member:login_form return="/{segment_1}/{segment_2}/{segment_3}/{segment_4}/"}
                        
                <div>/div> 
            Авторизация:
                        
                        <input type="text" name="username" value="Логин" maxlength="32" class="input" size="18"
                        />
                        
                        <input type="password" name="password" value="Пароль" maxlength="32" class="input" size="18"
                        /></p>
                        
                        <input type="submit" name="submit" value="  Вход  " /></p>
                        
                        a href="{path=member/register}">Регистрация</a> | <a href="http://{path=member/forgot_password}">Забыли пароль?</a>
                        
                        {/exp:member:login_form}
                
                    {/if}

    That my Safecracker form:

    {exp:safecracker channel="gallery" return="gallery" show_fields="not img-gallery|img-gallery-2" include_jquery="no"}      
    ...
    {/exp:safecracker}


    If I remove SafeCracker on this page, login is correctly.
    Please help me.

  • #2 / Aug 22, 2012 10:55am

    Shane Eckert

    7174 posts

    Hello 4ksner,

    I am sorry to hear you are running into this problem.

    I am unable to recreate this issue with that you have given me. Can you provide me with the entire SafeCracker form?

    Can you also tell what version of ExpressionEngine you are currently using?

    Thank you,

  • #3 / Aug 23, 2012 12:25am

    4ksner

    12 posts

    {exp:safecracker channel="sites" return="sites" use_live_url="yes" include_jquery="no"}
            
            <table border="0" cellpadding="5" cellspacing="5">
                <tr>
                    <td width="150">
                        <span>*</span> <b>Название:</b>
                    </td>
                    <td>
                        <input type="text" name="title" id="title" class="input" value="{title}" size="50" maxlength="75" title="Ограничение на длину названия — не более 75 символов" />
                        <input type="text" name="url_title" id='url_title' value="{url_title}" maxlength="75" size="1" /></p>
                        <input type="hidden" type="checkbox" name="status" value="open" checked />
                    </td>
                </tr>
                {custom_fields}
                <tr>
                    <td>
                        {if required}<span>*</span> {/if}
                        <b>{field_label}:</b>
    
                    </td>
                    <td>
                        
                        {if textinput}
                        <input type="text" dir="{text_direction}" id="{field_name}" class="input"
                         name="{field_name}" value="{field_data}" maxlength="{maxlength}" size="35" title="{field_instructions}" /></p>
                        {/if}
                        
                         
                    </td>
                </tr>
                    {/custom_fields}                     
                <tr>
                    <td colspan="2">
                        <input type="submit" name="submit" value="   Отправить   "  /></p>
                    </td>
                </tr>           
            </table>
            
        {/exp:safecracker}

    Here is what I have noticed in the source code of the page:
    If I use this code Safecracker:

    <div class='hiddenFields'>
    <input type="hidden" name="ACT" value="30" />
    <input type="hidden" name="RET" value="/add-site////" />
    <input type="hidden" name="site_id" value="1" />
    <input type="hidden" name="return" value="sites" />
    <input type="hidden" name="allow_comments" value="y" />
    </div>

    And if I remove Safecracker:

    <div class='hiddenFields'>
    <input type="hidden" name="ACT" value="9" />
    <input type="hidden" name="RET" value="/add-site////" />
    <input type="hidden" name="site_id" value="1" />
    </div>

    The same problem is also present on other pages where I use SafeCracker and Login form.

    I use 2.4.0 version.

  • #4 / Aug 23, 2012 2:56pm

    Shane Eckert

    7174 posts

    Hello 4ksner,

    Can you try form name on the login form?

    That should do it.

    Cheers,

  • #5 / Aug 23, 2012 3:10pm

    4ksner

    12 posts

    I added this parameter:

    {exp:member:login_form return="/{segment_1}/{segment_2}/{segment_3}/{segment_4}/" form_name="login"}

    but it did not help.

  • #6 / Aug 24, 2012 12:43pm

    Shane Eckert

    7174 posts

    Hey 4ksner,

    Can you paste in all your template code, I would like to try and reproduce it.

    Cheers,

  • #7 / Aug 25, 2012 1:24am

    4ksner

    12 posts

    I have good news.
    After your post, I began to remove all the excess from the template, until it was only two forms Safecracker and Member form:

    add-site.html:

    {embed="site/header"}
    
    {exp:safecracker channel="sites" return="sites" use_live_url="yes" include_jquery="no"}        
    {/exp:safecracker}

    header.html:

    {if logged_out}
                    
                        {exp:member:login_form return="/{segment_1}/{segment_2}/{segment_3}/{segment_4}/" form_name="login"}
                        
            <div>/div> 
            Авторизация:
             {if auto_login}
              input type="checkbox" name="auto_login" value="1"> Запомнить?
             {/if}      
              <div class="clear"></div>
                        
                        <input type="text" name="username" value="Логин" maxlength="32" class="input" size="18"
                        />
                        
                        <input type="password" name="password" value="Пароль" maxlength="32" class="input" size="18"
                        /></p>
                        
                        <input type="submit" name="submit" value="  Вход  " /></p>
                        
                        a href="{path=member/register}">Регистрация</a> | <a href="http://{path=member/forgot_password}">Забыли пароль?</a>
                        
                        {/exp:member:login_form}
                
                    {/if}


    This code does not work, I get error again, that Title field is empty.


    But, when I combined the two into one template:

    {if logged_out}
                    
                        {exp:member:login_form return="/{segment_1}/{segment_2}/{segment_3}/{segment_4}/" form_name="login"}
                        
            <div>/div> 
            Авторизация:
             {if auto_login}
              input type="checkbox" name="auto_login" value="1"> Запомнить?
             {/if}      
              <div class="clear"></div>
                        
                        <input type="text" name="username" value="Логин" maxlength="32" class="input" size="18"
                        />
                        
                        <input type="password" name="password" value="Пароль" maxlength="32" class="input" size="18"
                        /></p>
                        
                        <input type="submit" name="submit" value="  Вход  " /></p>
                        
                        a href="{path=member/register}">Регистрация</a> | <a href="http://{path=member/forgot_password}">Забыли пароль?</a>
                        
                        {/exp:member:login_form}
                
                    {/if}
            
        
    {exp:safecracker channel="sites" return="sites" use_live_url="yes" include_jquery="no"}
    {/exp:safecracker}

    It worked!

    Now, how do I make it so that they work in different templates?

  • #8 / Aug 27, 2012 2:02pm

    Shane Eckert

    7174 posts

    Hey 4ksner,

    It sounds like you might be running into Parse Order.

    {if logged_in} and {if logged_out} are parsed early.

    You might come at this differently.

    {if logged_in}
    {embed="site/header_logged_in"}
    {/if}
    {if logged_out}
    {embed="site/header_logged_out"}
    {/if}

     

    Contents of header_logged_out

    {exp:member:login_form return="/{segment_1}/{segment_2}/{segment_3}/{segment_4}/" form_name="login"}
    <div> </div> 
    Авторизация:
    {if auto_login}
    input type="checkbox" name="auto_login" value="1"> Запомнить?
    {/if}      
    <div class="clear"></div>
    
    <input type="text" name="username" value="Логин" maxlength="32" class="input" size="18"/>
    <input type="password" name="password" value="Пароль" maxlength="32" class="input" size="18"/></p>
    <input type="submit" name="submit" value="  Вход  " /></p>
    a href="{path=member/register}">Регистрация</a> | <a href="http://{path=member/forgot_password}">Забыли пароль?</a>
    {/exp:member:login_form}

    Contents of header_logged_in

    something here

    Does that makes sense? That gets the parse order in better shape.

    Thank you,

  • #9 / Aug 28, 2012 5:06am

    4ksner

    12 posts

    It did not work, it became even worse.

    If earlier this code worked on one page:

    {if logged_out}
                    
                        {exp:member:login_form return="/{segment_1}/{segment_2}/{segment_3}/{segment_4}/" form_name="login"}
                        
            <div>/div> 
            Авторизация:
             {if auto_login}
              input type="checkbox" name="auto_login" value="1"> Запомнить?
             {/if}      
              <div class="clear"></div>
                        
                        <input type="text" name="username" value="Логин" maxlength="32" class="input" size="18"
                        />
                        
                        <input type="password" name="password" value="Пароль" maxlength="32" class="input" size="18"
                        /></p>
                        
                        <input type="submit" name="submit" value="  Вход  " /></p>
                        
                        a href="{path=member/register}">Регистрация</a> | <a href="http://{path=member/forgot_password}">Забыли пароль?</a>
                        
                        {/exp:member:login_form}
                
                    {/if}
            
        
    {exp:safecracker channel="sites" return="sites" use_live_url="yes" include_jquery="no"}
    {/exp:safecracker}


    After a change to this code still does not work:

    {if logged_out}      
    {embed="site/header_logged_out"}            
    {/if}
    {exp:safecracker channel="sites" return="sites" use_live_url="yes" include_jquery="no"}
    {/exp:safecracker}

    It seems the problem is that {embed} parsed early than Safecracker. But this is contrary to Parse Order.

  • #10 / Aug 28, 2012 12:12pm

    Shane Eckert

    7174 posts

    Hey 4ksner,

    I think it might be helpful to login and help you out.

    Please be on the lookout for an email from EllisLab.

    Thank you,

  • #11 / Sep 05, 2012 5:33am

    Paul_B

    86 posts

    I’ve got the same issue going on - I’m getting *three*(!) separate hidden return fields in my login form; my safecracker form is wrapped in an {if logged_in} conditional and my login form is wrapped in {if logged_out}. The output hidden inputs look like this:

    CORRECT ONE:
    <input type=“hidden” name=“RET” value=”/ask-an-expert/post” />

    SAFECRACKER ONE:
    <input type=“hidden” name=“return_url” value=“ask-an-expert/post/success/ENTRY_ID” />
    WEIRD REPEATED SAFECRACKER FIELD:
    <input type=“hidden” name=“return” value=“ask-an-expert/post/success/ENTRY_ID” />

    Oddly the login form field has a different name, so I’d expect that to work and the others be ignored, but I guess ‘RET’, ‘return’ or possibly ‘return_url’ all work…?

    Did you find a solution to this issue?

  • #12 / Sep 06, 2012 4:52pm

    Shane Eckert

    7174 posts

    Hello Paul_B,

    We have not found a resolution at this point with 4ksner.

    Would you mind showing the entire form? Very interested in the safecracker form tag.

    Thank you,

  • #13 / Sep 06, 2012 5:24pm

    Paul_B

    86 posts

    Hi Shane

    No probs - my opening safecracker tag looks like this:

    {if logged_in}
    {exp:safecracker
        id="ask-an-expert-post"
        channel="ask-an-expert"
        return="ask-an-expert/post/success/ENTRY_ID"
        datepicker="no"
        include_jquery="no"
        class="nice"
        rte_selector=".WysiHat-field"
        rte_toolset_id="2"
        form_name="question"}
        <input type="hidden" name="status" id="status" value="Pending" />
    
        ...
    
        {/exp:safecracker} 
    {/if}

    My login form comes later in an embedded footer template, wrapped in {if logged_out} tags…

    {if logged_out}
    {exp:member:login_form id="login" class="nice" return="{if segment_1}/{segment_1}/{/if}{if segment_2}{segment_2}/{/if}"}
    ...
    {/exp:member:login_form}
    {/if}

    When I try to log in, I get an EE error page telling me that I must complete the title field.

     

  • #14 / Sep 07, 2012 12:23am

    4ksner

    12 posts

    Both forms are in the same template?

  • #15 / Sep 07, 2012 5:33am

    Paul_B

    86 posts

    No, the footer is an embed at the end of the template. The safecracker form is in the main template (not as an embed)

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases