Problems, need help? Have a tip or advice? Post it here.
13 posts Page 1 of 2
Member profile page.

when I set the input field to required='1' and type="bound", If the user leave it it blank and click submit, the error message didn't show up and it just submit the empty field instead.

The error message only shows up when i set the type="text". Any idea how to solve it?
Hey, I think it's because bound inputs are converted to regular inputs with a different name, other than frm_namehere (as in regular inputs). Please view-source in browser and find the converted name which has the input in html that was bound in code.
Nope. Just tested. The form does not show any error message about empty field, they just submit and updated the blank data instead.

I didn't change anything but follow the profile page in member addons. I even add required='1':

Code: Select all
<cms:input type="bound" name="k_page_title" Label="Name" placeholder="Name" required="1" /><br />
       
        <cms:input name="company_name" type="bound" placeholder='Company Name' Label='Company Name' required='1' /><br />
               
        <cms:input name="tel" type="bound" placeholder='Tel' Label='Tel' required='1' /><br />

        <cms:input type="bound" name="member_email" Label='Email' validator='email' placeholder='Email' required='1' /><br />

        If you would like to change the password type a new one. Otherwise leave this blank.<br />
        <cms:input type="bound" name="member_password" Label='New Password' placeholder='New Password' /><br />

        <cms:input type="bound" name="member_password_repeat" Label='Repeat New Password' placeholder='Repeat New Password' /><br />



For the CMS admin panel, the verification function for page title, member email are not working too. It's all pre-defined in original member form. How can I make it as a compulsory field? it cannot left empty.
Ok, could you add necessary restrictions to the <cms:editable /> itself? I think it would work.
what do you mean <cms:editable /> ?

What are you suggesting? I don't really get it. Sorry....
Note how you put "required='1'" for the <cms:input type='bound' /> and it didn't work. That's because 'bound' inputs inherit properties from the fields in admin panel, so if you put a " required='1' " to the field itself in you <cms:editable .. /> definition (in <cms:template/> block), it will work. More about editables here http://docs.couchcms.com/tags-reference/editable.html
no. It does not work.

Code: Select all
<cms:template title='Member Profile' hidden='1'>
   <cms:editable name='k_page_title' required='1' type='text' />
</cms:template>


Code: Select all
<cms:input type="bound" name="k_page_title" Label="Name" placeholder="Name" required="1" />


I put 2 of them. not working
You are using a system k_page_title, I don't know yet how to work with it, so maybe somebody can help here.
Hi,

The validation of fields in a data-bound form happens in two steps.
Let me explain. Following is an excerpt from the sample 'profile.php' of members addon -
Code: Select all
<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='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
</cms:if>

Please notice in the code above that there are *two* <cms:if k_success> checks -
When the form is submitted, all regular <cms:input>s in the form (i.e. those which are not type 'bound') are subjected to validation and if that succeeds the first <cms:if k_success > executes.

In that block there is the <cms:db_persist_form /> tag that now actually persists all 'bound' inputs into the backend.
It is at this spot that the validation of 'bound' input takes place. If the validation succeeds, the second <cms:if k_success > block executes.

Please note that in case of failure of any of the two success blocks, the *same* <cms:if k_error > executes.
This way we have a unified method of reporting failures for all kind of inputs.

Ok, with that theory past us, let us come to your original question -
If the user leave it it blank and click submit, the error message didn't show up

A 'bound' field takes all its parameters from the actual <cms:editable> defined in the template. If that region has 'required' set to '1', the bound field will automatically be a 'required' field. If not, placing that parameter within the <cms:input type='bound'> would be futile as parameters placed here are not taken into consideration at all for 'bound' inputs.

That should explain why the following is not working in your form -
Code: Select all
<cms:input type="bound" name="k_page_title" Label="Name" placeholder="Name" required="1" />

The 'k_page_title' is a core editable region and has its definition elsewhere in the system. By using 'bound' input you can only expose its existing functionality in the form but cannot otherwise change any parameters that have been originally defined (the 'required' parameter in your case).

Alright, so finally what can be done to make the title input as required on the form?

The answer is to use a normal <cms:input> of type 'text' with 'required' set to '1'.
This way the form won't submit (i.e. the first <cms:if k_success> block will not click) if the input is left empty.

Then upon successful submission of the form, push the value submitted though our normal input within the core 'k_page_title' field as follows -
Code: Select all
<cms:if k_success >
    <cms:db_persist_form
        k_page_title = frm_my_title
    />

    <cms:if k_success >
        <cms:set_flash name='success_msg' value='1' />
        <cms:redirect k_page_link />
    </cms:if>
</cms:if>

The code above assumes your input is named 'my_title' and hence we can get its submitted value by prepending 'frm_' to its name making it 'frm_my_title'.

Here is complete working sample showing only the one input being discussed -
Code: Select all
<cms:form 
    masterpage=k_member_template
    mode='edit'
    page_id=k_member_id
    enctype="multipart/form-data"
    method='post'
    anchor='0'
    >
   
    <cms:if k_success >
        <cms:db_persist_form
            k_page_title=frm_my_title
        />

        <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>
   
   
    DisplayName:<br />
    <cms:input type="text" name="my_title" label='DisplayName' style="width:200px;" required='1' /><br />
   
    <input type="submit" name="submit" value="Save"/>   

</cms:form>

Note the use of 'my_title' text input.

Hope it helps.
But if I set it as "text", the user details won't show up in input field like "bound" did.

And the worse part is the password and repeat password, the will also submit even if they don't match.
13 posts Page 1 of 2

Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 7 guests