Tomi14 Posted November 26, 2023 Share Posted November 26, 2023 I want to remove title field for reviews. If I remove lines 90-94 from post-comment-modal.tpl file, (with div "row" class), title field dissapear from review card, but I can't submit review, because title is still requied {if !$logged} <div class="row"> <div class="col-sm-8"> <label class="form-label" for="comment_title">{l s='Title' d='Modules.Productcomments.Shop'}<sup class="required">*</sup></label> <input id="comment_title" name="comment_title" type="text" value=""/> </div> <div class="col-sm-4"> <label class="form-label" for="customer_name">{l s='Your name' d='Modules.Productcomments.Shop'}<sup class="required">*</sup></label> <input id="customer_name" name="customer_name" type="text" value=""/> </div> </div> {else} <label class="form-label" for="comment_title">{l s='Title' d='Modules.Productcomments.Shop'}<sup class="required">*</sup></label> <input id="comment_title" name="comment_title" type="text" value=""/> {/if} Link to comment Share on other sites More sharing options...
Knowband Plugins Posted November 29, 2023 Share Posted November 29, 2023 On 11/26/2023 at 7:34 PM, Tomi14 said: If I remove lines 90-94 from post-comment-modal.tpl file, (with div "row" class), title field dissapear from review card, but I can't submit review, because title is still requied Hi, To achieve what you are trying to you have to comment multiple lines in the post-comment-modal.tpl file like below <div class="row"> {if !$logged} {* <div class="col-md-8 col-sm-8"> <label class="form-label" for="comment_title">{l s='Title' d='Modules.Productcomments.Shop'}<sup class="required">*</sup></label> <input name="comment_title" type="text" value=""/> </div> *} <div class="col-md-4 col-sm-4"> <label class="form-label" for="customer_name">{l s='Your name' d='Modules.Productcomments.Shop'}<sup class="required">*</sup></label> <input name="customer_name" type="text" value=""/> </div> {else} {* <div class="col-md-12 col-sm-12"> <label class="form-label" for="comment_title">{l s='Title' d='Modules.Productcomments.Shop'}<sup class="required">*</sup></label> <input name="comment_title" type="text" value=""/> </div> *} {/if} </div> Now when you have done that you need to go to the front controllers of the product comments modules/productcomments/controllers/front/PostComment.php and in the file check for the function validateComment and inside validateComment you need to comment from line no.170 to line no.174 like below private function validateComment(ProductComment $productComment) { $errors = []; // if (empty($productComment->getTitle())) { // $errors[] = $this->trans('Title cannot be empty', [], 'Modules.Productcomments.Shop'); // } elseif (strlen($productComment->getTitle()) > ProductComment::TITLE_MAX_LENGTH) { // $errors[] = $this->trans('Title cannot be more than %s characters', [ProductComment::TITLE_MAX_LENGTH], 'Modules.Productcomments.Shop'); // } if (!$productComment->getCustomerId()) { if (empty($productComment->getCustomerName())) { $errors[] = $this->trans('Customer name cannot be empty', [], 'Modules.Productcomments.Shop'); } elseif (strlen($productComment->getCustomerName()) > ProductComment::CUSTOMER_NAME_MAX_LENGTH) { $errors[] = $this->trans('Customer name cannot be more than %s characters', [ProductComment::CUSTOMER_NAME_MAX_LENGTH], 'Modules.Productcomments.Shop'); } } return $errors; } Please write here if you still face any issues. 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