nickzampieri Posted May 26, 2017 Share Posted May 26, 2017 Hello, We have a requirement that needs to have the create form for the user to allow peopple to enter their First and Last name as they wish. After that, we want those fields to be readonly as the primary key in a secondary system is based on the First and Last name. (I know its horrible but we don't have a choice) That being said, adding the following two lines to /themes/classic/templates/_partials/form-fields.tpl sort of works: {block name='form_field_item_other'} <input class="form-control" name="{$field.name}" type="{$field.type}" value="{$field.value}" {if $field.name === 'firstname'}readonly{/if} {if $field.name === 'lastname'}readonly{/if} {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if} {if $field.maxLength}maxlength="{$field.maxLength}"{/if} {if $field.required}required{/if} It adds the readonly tag to the the html and works well...however, this affect both the create user form and the my account | information form. I need to be able to make the My Account | Information form readonly for those two fields but read/write for the Create User form. Any ideas on how I could do this? If there was a way of detecting whether this is a new user or not, that would be very helpful. Thanks, Nick Link to comment Share on other sites More sharing options...
nickzampieri Posted May 26, 2017 Author Share Posted May 26, 2017 (edited) Hello, I managed to find a way by detecting whether the hidden "id_customer" was empty or not. If its empty, that means you are on the account creation page. If it has a value, then you are logged in and in the account information page. Here is the code I used: {if $field.name === 'id_customer'} {assign var="cust_id" value={$field.value} scope="root"} {/if} and: {block name='form_field_item_other'} <input class="form-control" name="{$field.name}" type="{$field.type}" value="{$field.value}" {if !empty($cust_id)} {if $field.name === 'firstname'}readonly{/if} {if $field.name === 'lastname'}readonly{/if} {/if} {if isset($field.availableValues.placeholder)}placeholder="{$field.availableValues.placeholder}"{/if} {if $field.maxLength}maxlength="{$field.maxLength}"{/if} {if $field.required}required{/if} Of course, modifying this file directly is not the best place to perform this according to the warning text at the top of the /themes/classic/templates/_partials/form-fields.tpl file. However, I am pretty new at this and don't really know how I would override this smarty tpl file and what folder would I use exactly? Thanks, Nick Edited May 26, 2017 by nickzampieri (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now