Jerome Campeaux
Jerome Campeaux

Reputation: 353

Spring form input can't be disable

I want to disable a <form:input> with the attribute disabled, but it's not working.

<td class="value">
                <sec:authorize access="hasAnyRole('ROLE_EDIT_DEVICE_INSTALL_DATE')">
                    <form:input path="installDt"  maxlength="10" size="10"  cssClass="installDatePicker" /> 
                    <form:errors path="installDt" cssClass="errormsg" />
                </sec:authorize>
                <sec:authorize access="!hasAnyRole('ROLE_EDIT_DEVICE_INSTALL_DATE')">
                    <form:input path="installDt"  maxlength="10" size="10"  cssClass="installDatePicker" disabled="disabled" /> 
                    <form:errors path="installDt" cssClass="errormsg" />
                </sec:authorize>  
</td>

Does anybody have any idea to solve it ?

Upvotes: 13

Views: 24426

Answers (4)

sushant097
sushant097

Reputation: 3736

When I place disabled="disable" it won't work

When I place disabled="true" the value in the receiving end is null

When I place readonly="true" It works for me.

Upvotes: 5

Gorkem Sevim
Gorkem Sevim

Reputation: 524

When I try to do input disable with disabled="true" , the data is null at core code, but when I try it with readonly, it did this properly.

Try readonly="readonly"

Upvotes: 11

Jerome Campeaux
Jerome Campeaux

Reputation: 353

I remove the cssClass date picker and set the disabled boolean to true and it works

Upvotes: 0

minion
minion

Reputation: 4343

To disable it, use disabled=true. It accepts true|false.

<form:input path="installDt"  maxlength="10" size="10"  cssClass="installDatePicker" disabled="true" />

Upvotes: 21

Related Questions