@madeby, you had asked -
To which my reply was -
As it turns out, we can, in fact, use 'secure' file with members module also.
Let me explain how.
As an example let us take the sample member registration form from the docs -
To add a 'secure' file to the mix, first define a securefile region in the members template e.g. as follows
Then amend the registration form as follows -
And now a registering user can upload her avatar along with the other data.
The trick above was to convert the form into a 'Databound' form by adding the 'masterpage' attribute pointing to the member template. The changes are highlighted below -
Hope it helps.
@kk So this is the only way of having a file attached to a sent form?
I would need it as part of the registration process for the members module, that is why I am asking
To which my reply was -
@madebym, for 'members' module this seems to be the only available option, I'm afraid.
For 'extended-users', however, we could use 'securefile' regions for the attachments during registration.
As it turns out, we can, in fact, use 'secure' file with members module also.
Let me explain how.
As an example let us take the sample member registration form from the docs -
- Code: Select all
<cms:form enctype="multipart/form-data" method='post' anchor='0'>
<cms:if k_success >
<!--
The 'member_process_registration_form' tag below expects fields named
'member_displayname', 'member_name' (optional), 'member_email',
'member_password' and 'member_password_repeat'
-->
<cms:member_process_registration_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='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>
Screen Name:<br />
<cms:input name='member_displayname' type='text' /><br />
Email Address:<br />
<cms:input name='member_email' type='text' /><br />
Password:<br />
<cms:input name='member_password' type='password' /><br />
Repeat Password:<br />
<cms:input name='member_password_repeat' type='password' /><br />
<input type="submit" name="submit" value="Create account"/>
</cms:form>
To add a 'secure' file to the mix, first define a securefile region in the members template e.g. as follows
- Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:template clonable='1' title='Members'>
<cms:member_define_fields />
<!--
Fields for 'email', 'password' and 'active' already come pre-defined.
If more fields are required, they can be defined here below in the usual manner.
-->
<cms:editable type='securefile' name='avatar' allowed_ext='gif, jpg, png' show_preview='1' required='1' />
</cms:template>
<?php COUCH::invoke(); ?>
Then amend the registration form as follows -
- Code: Select all
<cms:form enctype="multipart/form-data" method='post' anchor='0'
masterpage=k_member_template
mode='create'
>
<cms:if k_success >
<!--
The 'member_process_registration_form' tag below expects fields named
'member_displayname', 'member_name' (optional), 'member_email',
'member_password' and 'member_password_repeat'
-->
<cms:member_process_registration_form
_send_mail='0'
avatar=frm_avatar
/>
<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='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>
Screen Name:<br />
<cms:input name='member_displayname' type='text' /><br />
Email Address:<br />
<cms:input name='member_email' type='text' /><br />
Password:<br />
<cms:input name='member_password' type='password' /><br />
Repeat Password:<br />
<cms:input name='member_password_repeat' type='password' /><br />
Avatar:<br />
<cms:input name='avatar' type='bound' /><br />
<br />
<input type="submit" name="submit" value="Create account"/>
</cms:form>
And now a registering user can upload her avatar along with the other data.
The trick above was to convert the form into a 'Databound' form by adding the 'masterpage' attribute pointing to the member template. The changes are highlighted below -
<cms:form enctype="multipart/form-data" method='post' anchor='0'
masterpage=k_member_template
mode='create'
>
<cms:if k_success >
<cms:member_process_registration_form
_send_mail='0'
avatar=frm_avatar
/>
...
</cms:if>
..
Avatar:<br />
<cms:input name='avatar' type='bound' /><br />
..
</cms:form>
Hope it helps.