VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: catondesigngroup on January 24, 2016, 08:16:14 AM

Title: Need Text Input Custom Field to be Required
Post by: catondesigngroup on January 24, 2016, 08:16:14 AM
I've searched all over, and bought a couple plugins (rather not badmouth them) but I have yet to find a plugin that works which will make a text input field required.  Radio buttons, select list, yes I am able to make them required with Custom Fields For All.  But not text input.  Help?  There's got to be a (working) plugin out there for this, right?
Title: Re: Need Text Input Custom Field to be Required
Post by: Studio 42 on January 25, 2016, 09:48:52 AM
When you use the plugin provided by the core team, you can add this function

// this not permit to change value !
public function plgVmOnAddToCartFilter($product, $customfield, $customProductData, $customFiltered){
if ($customfield->custom_element !==$this->_name) return ;
if(empty($customProductData[$customfield->virtuemart_custom_id])) {
echo json_encode(array('stat' =>1, 'msg' => "You removed  the text input option")); jexit();
} else if(empty($customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id])) return ;
$selected = $customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id];
if( !$selected['comment'] ) {
echo json_encode(array('stat' =>1, 'msg' => "Please fell the text-input !"));
jexit();
}
}

If you dont use the modal popup, then this not work perfectly,you need to add a Joomla redirect.
Title: Re: Need Text Input Custom Field to be Required
Post by: hisslink on February 12, 2016, 14:55:55 PM
Thank you very much! Works perfectly for the textinput. I'm also using Custom Fields for All for all the other (required) custom fields. Also bought a plugin to make the textinput fields required, but this didn't work.
Title: Re: Need Text Input Custom Field to be Required
Post by: servlet on April 05, 2016, 13:19:24 PM
Where to input this code?
Thank you
Title: Re: Need Text Input Custom Field to be Required
Post by: Studio 42 on April 05, 2016, 22:33:48 PM
@servlet : In the virtuemart text input plugin class
file : YOURJOOMLASITE\plugins\vmcustom\textinput\textinput.php
inside class plgVmCustomTextinput extends vmCustomPlugin {
Best at end before } closing tag
Title: Re: Need Text Input Custom Field to be Required
Post by: servlet on April 06, 2016, 07:40:06 AM
thank you
I will try
Title: Re: Need Text Input Custom Field to be Required
Post by: doc_denis on September 28, 2016, 19:48:41 PM
Merci monsieur ;)
ça fonctionne très bien, super pratique le petit message en pop-up.
reste à ajouter une liaison avec le fichier le langue pour le multilingue.
Merci
c'est un truc à ajouter dans un autre lieu, non?
Title: Re: Need Text Input Custom Field to be Required
Post by: aftertaf on January 22, 2017, 18:02:37 PM
i need this too for selling gift certificates that are sent by mail.

1- is there a safe way to use this as an override in the template ? In case VM updaes I wouldn't want to lose it.
2- Can the text be replaced by language overrides (i'd be needing it for multilingual site), like i see in other php files ? e.g. <?php echo vmText::_ ('COM_VIRTUEMART_NEED_MAIL_ADDRESS')?>


I confirm that the change works fine, as long as you paste it in the right part of the .php file :)
Title: Re: Need Text Input Custom Field to be Required
Post by: mhuebler on May 03, 2017, 19:55:32 PM
Is there someone can help to make this work with template override ?
Title: Re: Need Text Input Custom Field to be Required
Post by: Studio 42 on May 04, 2017, 02:33:46 AM
You have all explains here. For Joomla overrides, Google is your friend ;)
If you need a developer, contact me or any other developer in the forum for a custom work.
Title: Re: Need Text Input Custom Field to be Required
Post by: servlet on October 28, 2017, 07:54:11 AM
It works, but fancy box is so small. It is different from other like add to cart and ask a question
Please give mi a hint how to change this fancy box, which file.
Title: Re: Need Text Input Custom Field to be Required
Post by: Studio 42 on October 28, 2017, 13:48:07 PM
If you modify the text and adding a <DIV> or add inline style.
I think it can be solved with some CSS rules
Title: Re: Need Text Input Custom Field to be Required
Post by: servlet on October 28, 2017, 16:44:40 PM
Thank you
I will try
Title: Re: Need Text Input Custom Field to be Required
Post by: aftertaf on October 29, 2017, 21:43:49 PM
Hi,

I haven't made any changes that I remember on this setup. It was working before.
Now I get the ajax popup 'you removed the text input option' but like i said, i dont think i modified this custom field since it was setup and tested working (with mandatory typing of data in it)
Any Idea what could be amiss?
this is obviously being triggered but i cant figure out why...


if(empty($customProductData[$customfield->virtuemart_custom_id])) {
echo json_encode(array('stat' =>1, 'msg' => "You removed  the text input option")); jexit();
Title: Re: Need Text Input Custom Field to be Required
Post by: T.A. Garrison, LLC on May 10, 2023, 02:59:40 AM
This thread is old, but the text input field (VM Custom - Customer text Input) STILL has problems.

I have spent all day today trying variations to get it to work, but no luck.

The field by itself works.
But if you "Require" a specific number of characters (Minimum required letters), then the "Add to Cart" will not appear. It's hidden.

After trying all sorts of variations, I get it to work ONLY if it's a Parent product. If it's a Child product, then it will not work.

BUT...it does not work 100% no matter what I do.
I can get the "Add to Cart" to display if it's a Parent product with the Minimum required letters set, but the Quantity does NOT display to the left of "Add to Cart". So there is no way for the customer to select more than 1 quantity until they get to the cart.
My client "must" have this working because he sells massive quantities of individual products. Expecting the user to "know" they need to go to the cart to increase the quantity is not good. And, the Quantity Discounts do not work when the text input field has a Minimum required letters.

I cannot get anybody to respond where we are now "supposed" to post tickets, so I'm back in the forum in this 8 year old thread!

I'm using Joomla 4.3.1 with VM 4.0.20
I really hope someone can help on this.
This is the third issue I currently have with VM and I'm unable to get anybody to respond - for more than a month now.