Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi again!

It's most likely a very minor detail I'm missing, but I can't get this to work. If I put a specific value for user_select it works, but I would prefer very much to get the username chosen in the dropdown field. Wouldn't make sense otherwise ;).

Code: Select all
<cms:set user_select="<cms:get_flash 'user_select' />" />
         <cms:if user_select >
            <p>Selected member: <cms:show user_select/></p>
         </cms:if>
         
         <cms:form enctype="multipart/form-data" method="post" anchor='0'>
            
            <cms:if k_success >
               <cms:set_flash name='user_select' value=frm_user_edit />
               <cms:redirect k_page_link />
            </cms:if>
               
            <cms:if k_error >
               <font color='#be2226'><cms:each k_error ><cms:show item /><br /></cms:each></font>
            </cms:if>
            
            <div>
               Choose Member to edit:<br />
               <div class="select-wrapper">
               <cms:input name='frm_user_edit' type='dropdown'
               opt_values="Select Member=- | Username1 | Username2"
               required='1'/>
               </div>
            </div>
            <div>
               <input type="submit" name="submit" value="Save"/>   
            </div>
         </cms:form>
Hi,

If an input is named, say, 'something', in k_success block its value will be available as a variable named 'frm_something' (i.e. by appending a 'frm_' to the input's name').

In your case, the input's name is 'frm_user_edit', so the variable containing its submitted value will be 'frm_frm_user_edit'

So you can do either of the following two things -
1. Use 'frm_frm_user_edit'
Code: Select all
<cms:set_flash name='user_select' value=frm_frm_user_edit />

2. Rename the cms:input to 'user_edit' instead of the current 'frm_user_edit'
Code: Select all
<cms:input name='user_edit' type='dropdown' ..

Hope this helps.
Yes it does, thank you! Although now I'm facing a different problem. My idea was to use the former form to select the user which data should be possible to edit with the second. Unfortunately I can't get the second to work. I know I edit only the logged in user for now (changing this shouldn't be a problem) but I can't make changes there:
Code: Select all
<cms:set success_msg="<cms:get_flash 'success_msg' />" />
            <cms:if success_msg >
                  <p>Profile updated.</p>
            </cms:if>
            
            <cms:form enctype="multipart/form-data" method="post" anchor='0'>
            
               <div class="row">
               
                  <cms:if k_success >
                     <cms:set_flash name='user_select' value=frm_user_edit />
                     <cms:redirect k_page_link />
                  </cms:if>
                     
                  <cms:if k_error >
                     <font color='#be2226'><cms:each k_error ><cms:show item /><br /></cms:each></font>
                  </cms:if>
                  
                  <div class="8u">
         
                     <div class="select-wrapper">
                     <cms:input name='user_edit' type='dropdown'
                     opt_values="Select Member=- | <cms:pages masterpage='users/index.php' order='asc'><cms:show k_page_title/>=<cms:show k_page_name/> | </cms:pages>"
                     required='1'/>
                     </div>
                     
                  </div>
                  
                  <div class="4u">
                  
                     <input type="submit" name="submit" value="Save"/>
                     
                  </div>
               </div>
            </cms:form>
            </div>
         
            <cms:set user_select="<cms:get_flash 'user_select' />" />
            <cms:if user_select >
            
            <div class="12u">
               
               <cms:form
                  masterpage=k_user_template
                  mode='edit'
                  page_id=k_user_id
                  enctype="multipart/form-data"
                  method='post'
                  anchor='0'
                  >
                  
                  <cms:if k_success >
                     <cms:db_persist_form />

                     <cms:if k_success >
                        <cms:set_flash name='success_msg' value='1' />
                        <cms:redirect k_page_link />
                     </cms:if>
                  </cms:if> 
                  
                  <cms:if k_error >
                     <font color='#be2226'><cms:each k_error ><cms:show item /><br /></cms:each></font>
                  </cms:if>
                  <div class="row uniform">
                     <div class="2u 4u(3) 12u$(4)">
                        Gender:<br /><div class="select-wrapper">
                        <cms:input name='user_gender' type='bound'/>
                     </div></div>
                     <div class="5u 8u(3) 12u$(4)">
                        Name:<br />
                        <cms:input name='k_page_title' type='bound' placeholder="Name" />
                     </div>
                     <div class="12u$">
                        <input type="submit" name="submit" value="Save"/>   
                     </div>
                  </div>
               </cms:form>
            </div>
            
            </cms:if>
Klaus,

Using flash-data for selecting which form to show will be tricky as the flash-data lasts for only one page refresh. Submit the second form and the flash-data disappears (unless you explicitly reset it).

Not that it is not doable (I think you'll find a post on this forum where the OP does exactly this) but it is overly complex and unmanageable.

My suggestion is that you please use the method shown in the 'Advanced tutorial' - viewtopic.php?f=5&t=8981

You should find that method much clearer.
Thanks! Would session variables do it?

The advanced tutorial seemed for my purposes a bit too much, but I'll look into it. Is there somewhere where I can already skip to to help with my problem or should I start at the beginning?
I'd still say that please take a look at the method shown in the advanced tutorial.

If, however, you wish to pursue your original method, following is the thread I mentioned which used the flash-data -
viewtopic.php?f=4&t=8615&p=16540

I'd also like to mention that in your code you are persisting 'k_page_name' as flash-variable. You should, I think, save 'k_page_id' instead and then use it with the second form (instead of k_user_id).

Hope it helps.
6 posts Page 1 of 1
cron