Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
I have form with "Followers" relation type inside.
I have done with adding followers into related users, but it always replace the the current followers instead of adding it into the list.

Editable code:
Code: Select all
<cms:editable type='relation' name='followers' label='Following' title='Followers' masterpage='users/index.php' has='many'/>

My form code:
Code: Select all
<cms:form
            masterpage='users/index.php'
            mode='edit'
            enctype='multipart/form-data'
            page_id=k_page_id
            method='post'
            anchor='0'
            >           
       
<cms:if k_success >
           <cms:db_persist_form
           followers=k_user_id
/>
</cms:if>     
       
<cms:input class="sh-btn sh-btn-small" name="submit" type="submit" value="Follow" />
       
</cms:form>


One more thing, if the current logged in user "Authenticate User" it says "Cheating" when submitting.
Need help.

Thank you.
but it always replace the the current followers instead of adding it into the list.

Please amend the following portion of your code -
Code: Select all
<cms:db_persist_form
    followers=k_user_id
/>

To make it as follows -
Code: Select all
<cms:db_persist_form
    followers="+<cms:show k_user_id />"
/>

The 'plus' sign you see above will signal to Couch to add the new value to existing values(s) (instead of replacing them with the new).

If, in some other use-case, you desire to selectively remove a value from a set of existing ones, you may use a 'minus' sign instead.

Hope this helps.
Thankyou so much KK,

You're the man.
One more thing KK, I have done with the followers thing.
But, i didn't know how to make the list of following by the users.

Example:
User A follow User B
So at the User A Following Page must be User B in there...

How to make that happen?
Thankyou.
4 posts Page 1 of 1